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;
}
}
精彩评论