Reputation: 2189
According to Raywenderlich, the app goes to inactive state.
Inactive: When your app is running but something happens to interrupt it, like a phone call, it becomes inactive. Inactive means that the app is still running in the foreground but it’s not receiving events.
So, does the video get paused automatically like it does when the app goes to background. Or Do we have to set an observer for such interruption and manually set the AVPlayer rate=0 (in order to pause)? If the later one is true then which property should we observe?
Upvotes: 0
Views: 1795
Reputation: 1190
There are observable NSNotification properties the player emits. This includes interruptions for more than just phone calls such as audio route changes.
Check out this post
Your app goes into an inactive state depending on your audio playback setup. Whenever the phone call/interruption ends, based on your playback, iOS will signal your app that the interruption has ended and it's your responsibility to handle what happens to your audio playback after the interruption has stopped.
Note, you MUST make every effort to handle interruptions properly. If you wanted to be malicious, but probably rejected from the app store, you could make it so that regardless of interruptions your playback always resumed. What you will see happen is that BOTH your audio playback and the phone call audio will happen simultaneously. So your audio route will change to the "headset" and playback could resume from the headset and the phone call will also continue.
I've also seen (in iOS 8 at least) the interruption notification is prematurely called when on a bluetooth handsfree device specifically in cars (such as Toyota). I've had on many occasions where Spotify will continue to playback WHILE I'm also on a phone call...quite annoying. I don't think this is a bug on Spotify's part because Apple Music player does the same thing on occasion so it may be an SDK bug. I've seen radars for this as well. Just as a warning to you.
Upvotes: 1