2

I have an app that uses AVPlayer (or AVQueuePLayer) to play local files that were recorded by the App. All works great. But I also want this to work on iPhone when a call is in progress (the videos are event recordings). What I found is that during a phone call, the video feed to avplayerLayer goes blank, AVPlayer rate change to 0 (STOP), and all attempts to change rate to non-zero (PLAY) are ignored (rate stays at 0). There does not appear to be any documentation on this, and the only way to detect this condition in the player, is that player is STOPPED and will not start PLAYBACK. Of course, I also check for audio interruptions, and call center calls in progress.

Obviously, in this case the interruption is caused by a call, so there is always a inactive/resume or a intactive/background/foreground/resume transition. As well as audio route notification, audio interruption. So indirectly I know the condition is probably occurring.

So questions are: (1) Is there any direct method (specific to AVPlayer,AVPlayerLayer) to be notified that AVPlayer is in this non-playing mode. I now use "avplayer.rate failed to change rate from 0 to non-zero", but this seems hacky (and too much "crossing the streams"!) I want to Notify user that video temporarily can not be played or previewed, so they do not think the App is broken. And also inform them or automatically continue Playback when iPhone call ends. (Without a looping process that keeps trying to start playback every 500ms!)

(2) Can AVPlayer play anything while a iPhone call (Green Bar) is in progress? or is this just the way apple designed the AVPlayer SDK? (If so there is no documentation on this) Obviously, other apps can play video during an iPhone call, but I suspect they are using a lower level SDK and not AVPlayer.

Dharmesh Dhorajiya
  • 3,976
  • 9
  • 30
  • 39
  • Note: Further research added a tiny bit of help. Using AVPlayerLayer delegate, and "ready to display" and "videoRect:" you can determine if video is being displayed. This allows removing or hiding junk or frozen video, or an empty view. So another VERY indirect method to know AVPlayer is not working. – Kirk Topits Apr 13 '15 at 19:29
  • "_If your user's device receives a phone call or a FaceTime call when your application is playing a particular file, your playback is interrupted so that your user can answer their call. In this case, if you're using KVO on the player's rate, you would see it transition to zero.This is a good way for you to be notified of such interruptions so that you do not end up waiting endlessly for playback to end._" **Source:** [WWDC 2014 Transcript](http://asciiwwdc.com/2014/sessions/503). You can watch the [WWDC 2014 session 503](https://developer.apple.com/videos/play/wwdc2014/503/) for details. – Utsav Dusad Apr 25 '16 at 08:55

0 Answers0