I have some questions related to AVPlayer which are:
-
When we pause the
AVPlayerthrough[player pause]does theAVPlayerkeep buffering the video from the network or does it just stop? I couldn’t get any info related to this in apple’s documentation. Also, is it possible to force the AVPlayer to keep buffering while in pause, so that if we have the paused video is in waiting for the first video to be ended then we wouldn’t find any gap in between the videos? -
On pausing the
AVPlayercan we have any event on[player pause]. -
Can we show still image on
AVPlayerfor some seconds?
Thanks
1)
AVPlayerwill buffer the video in several cases, none cleary documented. I’d say you can expect buffering when you init the video, and when you replace the current item.You can observe
currentItem.loadedTimeRangesto know what’s going on. That property will tell you which video time ranges has been loaded.Also, there is a few other
currentItemproperties that may help you:playbackLikelyToKeepUp,playbackBufferFullandplaybackBufferEmpty.Achieving a perfect gapless playback is not easy.
In
observeValueForKeyPath:ofObject:change:context::2) Just keep an eye on
player.rate.Then in your
observeValueForKeyPath:ofObject:change:context::3) You can build a movie of a given length using a still image but it’s easier to use a regular
UIImageViewon top of the player. Hide/show it when needed.Sample project: feel free to play with the code I wrote to support my answer.