I have an application that plays videos using AVPlayer and AVPlayerLayer . In my application, I can play audio when the application is locked by setting the player property of my AVPlayerLayer to nil when the application goes into the background:
-(void)appEnteredBackgroundNotification:(NSNotification *)notification { [[self playerLayer] setPlayer:nil]; }
However, when I do this, the sound will lag / reset by about 0.5 seconds. This is really very bad for the end user. The same thing happens when the application comes to the forefront and I re-set the player property.
How can I avoid this sound? As a test, I tried to remove the player in the background thread to no avail.
Update: I spoke with an Apple engineer at WWDC, and they said that this problem is a bug at their end (until it is fixed in iOS 9), and this approach is the right approach. Big...
ios avplayer avplayerlayer
Aaron wojnowski
source share