During video playback, I see speed change notifications from AVPlayer, which, it seems, are not related to the activity of the application.
When my application receives a notification UIApplicationDidEnterBackgroundNotification, I point AVPlayerto pause. The logic is that it should return to the foreground in the same place in which the user has left. If I do not call pausein the transition to the background, the problem does not arise.
The sequence of events that are sent to the player, is pause, seekToTime:, play. This usually works fine, but after the application has been sent to the background and then returned to the forefront, each call playresults in two speed changes from AVPlayer. The first is 1, and the second, immediately following, is 0. This pattern continues for each call -[AVPlayer play]while this player instance is being used.
I can put a breakpoint on -[AVPlayer pause], and I donโt see it hit when the speed changes to 0. If I comment on the call seekToTime:, the problem will disappear. If I use seekToTime:completionHandler:, I also get the same problem, although my parameter is finished YES.
Besides โhow to fix it,โ Iโm interested in any details on how to determine the cause of speed changes in AVPlayerthat are not connected to play/ pause. (Putting a breakpoint on -[AVPlayer setRate:]never fires.)
(One of the workarounds that almost works is to keep the playerโs position when entering the background, let him play and fix the position when returning to the foreground. It also requires some manipulation of sound levels, which is probably possible but another problem is that not all background notifications indicate that the view was closed (for example, double-click the home button). This leads to cases where my crawl shows a distracting moving image when the application is interrupted, but still visible.)
?
( : , , , AVPlayer 1 0 , "", , . , , , , AVPlayer . , , ... .
, , , . , ( /), .)