Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification for MPMoviePlayerViewController when the entire file is not available?

Tags:

iphone

video

All,

This is regarding Question on iPhone , playing video

My app is downloading a youtube file and at the same time, i want to play the video from the local.

Am able to do this using MPMoviePlayerViewController, but i donot receive any notifications if the player has stopped playing half-way as the entire file content was not available.

e.g. say a 10MB content of 5 minutes video is currently downloading and the downloading is stopped, the App has just downloaded 5 MB or 2.5 minutes of the video, when i play the video, i am be able to view the video until 2.5 minutes but i donot receive any notification after the video has stopped playing.

Is there a notification that tells "video content not available" "end of movie"

--Srihari

like image 857
srihariv Avatar asked Dec 28 '22 14:12

srihariv


1 Answers

Per MPMoviePlayerController Class Reference

MPMovieFinishReason

enum {
  MPMovieFinishReasonPlaybackEnded,
  MPMovieFinishReasonPlaybackError,
  MPMovieFinishReasonUserExited
};
typedef NSInteger MPMovieFinishReason;

Notification

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(playbackFinished:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification 
                                           object:nil];

Example

- (void)playbackFinished:(NSNotification*)notification 
{
    NSNumber * reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
    switch ([reason intValue]) {
        case MPMovieFinishReasonPlaybackEnded:
            NSLog(@"Playback Ended");         
            break;
        case MPMovieFinishReasonPlaybackError:
            NSLog(@"Playback Error");
            break;
        case MPMovieFinishReasonUserExited:
            NSLog(@"User Exited");
            break;
        default:
            break;
    }
}
like image 76
WrightsCS Avatar answered Dec 30 '22 02:12

WrightsCS