Skip to content

Instantly share code, notes, and snippets.

View lstonussi's full-sized avatar
🎯

lstonussi

🎯
View GitHub Profile
@netgfx
netgfx / addObservers.swift
Last active June 8, 2024 04:59
Add observers to AVPlayer
// listening for current item change
self.audioQueueObserver = self.playerQueue?.observe(\.currentItem, options: [.new]) {
[weak self] (player, _) in
print("media item changed...")
}
// listening for current item status change
self.audioQueueStatusObserver = self.playerQueue?.currentItem?.observe(\.status, options: [.new, .old], changeHandler: {
(playerItem, change) in
if playerItem.status == .readyToPlay {