iPhone: What is MPMusicPlaybackStateInterrupted? And what is difference between it and MPMusicPlaybackStatePaused

StackOverflow https://stackoverflow.com/questions/11537321

Question

I have some questions about MPMusicPlayerController's playbackState properties.

In the document, MPMusicPlaybackStateInterrupted and MPMusicPlaybackStatePaused are defined as follows:

MPMusicPlaybackStateInterrupted
The music player has been interrupted, such as by an incoming phone call.

MPMusicPlaybackStatePaused
The music player is paused.

I can't check incoming phone call because I don't have iPhone now.
But only a few times I got MPMusicPlaybackStateInterrupted state while just playing music with iPod touch.

(I don't know why the interrupted state happened. There was no incoming phone call and no other operations except for just playing music).

And at those times, MPMusicPlayerController just paused playing music.

Question1
What is the difference between MPMusicPlaybackStateInterrupted and MPMusicPlaybackStatePaused?

Question2
When does MPMusicPlaybackStateInterrupted happen except for incoming phone call?

Question3
What should I do when I get MPMusicPlaybackStateInterrupted?
For example, when I get MPMusicPlaybackStatePaused or MPMusicPlaybackStateStopped, I should change play/pause button.

Was it helpful?

Solution

I confirmed the following information with iOS 5.1.1.

Question1
What is the difference between MPMusicPlaybackStateInterrupted and MPMusicPlaybackStatePaused?

MPMusicPlaybackStatePaused happens when the player paused.
MPMusicPlaybackStateInterrupted happens when the player is interrupted by other audio output such as incoming phone call or timer of Apple's Clock app.

Question2
When does MPMusicPlaybackStateInterrupted happen except for incoming phone call?

MPMusicPlaybackStateInterrupted happens when timer of Clock app rings.
-applicationWillResignActive: also is called when the timer rings.
But MPMusicPlaybackStatePaused doesn't happen and playing music is automatically resumed after interruption (the alarm of the timer) finished.

Other examples of interruption are Siri/Voice Control(hold down home button), remote control of earphone(if you use applicationMusicPlayer), incoming phone call.
Pushing play button of remote control of earphone doesn't make the app resign active. And the interruption never finish.

MPMusicPlaybackStateInterrupted doesn't happen and playback state doesn't change when notification banner appears on top of the screen.
VoiceOver also doesn't generate interruption.

Question3
What should I do when I get MPMusicPlaybackStateInterrupted?
For example, when I get MPMusicPlaybackStatePaused or MPMusicPlaybackStateStopped, I should change play/pause button.

You don't have to do anything in callback of MPMusicPlayerControllerPlaybackStateDidChangeNotification when MPMusicPlaybackStateInterrupted happens.
Because playing music is automatically resumed after interruption.

EDIT
I found that infrequently playing music is not resumed automatically.(That means you can't rely on automatic resume.)

And in the following cases playing music is not resumed automatically.

  • When remote control button of earphone was pushed. (if you use applicationMusicPlayer)

  • When timer rang, you double-tap home button, switch application, stop timer, and switch back to the application.

  • When you switched back to the app while you are calling after you accepted incoming call.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top