In iOS AVPlayer, addPeriodicTimeObserverForInterval seems to be missing
Check this func addPeriodicTimeObserver(forInterval interval: CMTime,
queue: DispatchQueue?,
using block: @escaping (CMTime) -> Void) -> Any
It is in the documents also for example check this code snippet
let timeObserverToken = player.addPeriodicTimeObserver(forInterval: interval, queue: DispatchQueue.main) { [unowned self] time in
}
Referenced from here
AVPlayer removing a periodicTimeObserver
Glad to see weakSelf worked for you ...
In the above I don't see you assigning the result of
[player addPeriodicTimeObserverForInterval ...
to self.timeObserver it may be a typo but it should be ;
self.timeObserver = [player addPeriodicTimeObserverForInterval ...
if you intend to call
[player removeTimeObserver:self.timeObserver];
you also missed the ";" above.
Is KVO on AVPlayerItem.loadedTimeRanges possible?
Actually, I'm using KVO for loadedTimeRanges without any trouble. Maybe you're just not setting the right options? The following is a very slight modification of some of the code in Apple's AVPlayerDemo, and it's working quite nicely for me.
//somewhere near the top of the file
NSString * const kLoadedTimeRangesKey = @"loadedTimeRanges";
static void *AudioControllerBufferingObservationContext = &AudioControllerBufferingObservationContext;
- (void)someFunction
{
// ...
//somewhere after somePlayerItem has been initialized
[somePlayerItem addObserver:self
forKeyPath:kLoadedTimeRangesKey
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
context:AudioControllerBufferingObservationContext];
// ...
}
- (void)observeValueForKeyPath:(NSString*) path
ofObject:(id)object
change:(NSDictionary*)change
context:(void*)context
{
if (context == AudioControllerBufferingObservationContext)
{
NSLog(@"Buffering status: %@", [object loadedTimeRanges]);
}
}
Is there a free or commercial dvd burner sdk for cocoa?
Apple provide an API of their very own: the Disc Recording Framework.
There is even a Disc Recording UI Framework, too.
Related Topics
Please Specify a Platform for This Target in Your Podfile
Ios10, Swift 3, and Fcm Delegate Error
Firebase Dynamic Link Doesnt Work in Safari Swift
Xcode 6 Project Crashing After Segue on iOS 7.1
How to Hide API Keys in Github for iOS (Swift) Projects
Avaudiocompressedbuffer to Uint8 Array and Vice Versa
Apple Healthkit - Background Updates Not Triggering
Why am I Getting Com.Facebook.Sdk.Login Error 308
How to Handle Homophones in Speech Recognition
How to Simultaneously Satisfy Constraints with Keyboard and Uitoolbar
How to Store Array in Nsuserdefault in Swift
Swift - Could Not Cast Value of Type 'Uitabbarcontroller'
Swift Core Data Sync with Web Server
Uidocumentinteractioncontroller() Swift