开发者

Notification for MPMoviePlayerViewController when the entire file is not available?

开发者 https://www.devze.com 2023-04-03 21:39 出处:网络
All, This开发者_StackOverflow社区 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.

All,

This开发者_StackOverflow社区 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


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;
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号