Question

I'm currently developing a web-tv application that uses MPMoviePlayerViewController resp. MPMoviePlayer to playback streaming video content on the iphone.

the issue I've got here is that once i unplug my headphones (while watching tv) the player stops. Due to the fact that I'm not showing the standard controls (previous button, play/pause button, next button) but my custom controlls, the user is stuck with the frozen picture unless he switches to a new channel..

is there any way to detect a playback interuption caused by unplugging the headphones?

thanks for your tipps and tricks in advance,

sam

Was it helpful?

Solution

I don't have a direct answer to your question. But I think MPMoviePlayerPlaybackStateDidChangeNotification will be good enough to solve your issue. Once you are notified, Get the playback state from the playbackState property of the movie player object and take appropriate action.

OTHER TIPS

Elaborating on the accepted answer with some code:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(videoPlaybackStateChanged:)
                                             name:MPMoviePlayerPlaybackStateDidChangeNotification
                                           object:moviePlayer];


- (void)videoPlaybackStateChanged :(NSNotification *)notification
{
    if (moviePlayer != nil && [moviePlayer playbackState] == MPMoviePlaybackStatePaused)
    {
        [moviePlayer play];
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top