1
不工作我有一個建立在演示我只是從直播網址播放視頻,如果網址不MPMoviePlayerPlaybackDidFinishReasonUserInfoKey。這件事的工作完全在ios7和更大的正常工作,然後火的MPMoviePlayerController通知MPMoviePlayerPlaybackDidFinishNotification但是當我在ios6中使用相同的東西時,它不起作用。 我的一小段代碼片段是繼的MPMoviePlayerController通知在iOS6的
NSLog(@"URL::%@",url.absoluteString);
UIInterfaceOrientation interface = [UIApplication sharedApplication].statusBarOrientation;
videoPlayer = [[MPMoviePlayerController alloc] init];
[videoPlayer setContentURL:url];
[videoPlayer setMovieSourceType:MPMovieSourceTypeStreaming];
[videoPlayer setControlStyle:MPMovieControlStyleNone];
[videoPlayer setScalingMode:MPMovieScalingModeNone];
[videoPlayer.view setFrame:CGRectMake(0.0, viewTopbar.frame.size.height, self.view.frame.size.width, self.view.frame.size.height - (viewTopbar.frame.size.height+[self getBannerHeight:interface]))];
[self.view addSubview:self.videoPlayer.view];
[self.videoPlayer play];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:videoPlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinishWithReson:)
name:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey
object:videoPlayer];
#pragma mark
#pragma mark - movie player delegate methods
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
int reason = [[[notification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue];
if (reason == MPMovieFinishReasonPlaybackError) {
//error
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:localize(@"strTitle") message:localize(@"strMsg") delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}
-(void) moviePlayBackDidFinishWithReson:(NSNotification *)notification
{
int reason = [[[notification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue];
if (reason == MPMovieFinishReasonPlaybackError) {
//error
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:localize(@"strTitle") message:localize(@"strMsg") delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}