This is not a structural error, but related to how key monitoring works. Introducing
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
in your ViewController, you override the implementation of AVPlayerViewController. The solution is to add context when registering the observer:
static NSString* const AVPlayerStatusObservationContext = @"AVPlayerStatusObservationContext";
then register your observer as follows
[self.player addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionPrior context:(__bridge void *)(AVPlayerStatusObservationContext)];
and follow these steps in watchValueForKeyPath
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (context == (__bridge void *)(AVPlayerStatusObservationContext)) { NSLog(@"Change Object %@, Value %@",object,change); } else { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } }
source share