iOS中,MPMoviePlayer退出全屏通知不起作用

3
我正在使用webview加载youtube视频。由于我的应用是在线电台应用,因此无线电在后台播放。当我点击webview时,它会将视频重定向到mpmovieplayer的全屏模式中。 我想要的是,当有人点击webview或mpmovieplayer开始播放视频时,无线电应该暂停。但我如何追踪mpmoviepayer何时开始播放并退出全屏模式。我还在我的viewdidload方法中设置了MPMoviePlayerDidExitFullscreenNotification通知,但从未被调用。
self.videoTitleLabel.text = videoInfo.videoTitle;

//NSString *vidUrl = [videoInfo.videoURL stringByReplacingOccurrencesOfString:@" " withString:@"%20"];

CGSize scrSize = [[UIScreen mainScreen] bounds].size;//appDel.window.frame.size;

float imgSclToX = scrSize.width/16.0;

int imgWidth = (int) (scrSize.width -18);
int imgHeight = (int) ((float)(9.0)*imgSclToX);

// DebugLog(@"Yo-----> Window: %@ Width: %i Height: %i", NSStringFromCGSize(scrSize), imgWidth, imgHeight);

NSString *htmlStr = @"";
// htmlStr = [htmlStr stringByAppendingFormat:@"<iframe width=\"%i\" height=\"%i\" src=\"%@\" frameborder=\"0\" allowfullscreen></iframe>", imgWidth, imgHeight, vidUrl];

NSString *tStr = videoInfo.videoURL;
// NSString *tStr = @"https://www.youtube.com/watch?v=yz_j7nVCJJ0";
tStr = [tStr substringFromIndex:([tStr rangeOfString:@"v="].location+2)];

htmlStr = [NSString stringWithFormat:@"<iframe  type=\"application/x-shockwave-flash\" width=\"%i\" height=\"%i\" src=\"https://www.youtube.com/embed/%@\" frameborder=\"0\" allowfullscreen></iframe>", imgWidth, imgHeight, tStr];

NSString *embedHTML = [NSString stringWithFormat:@"<html><head></head><body>%@<p><b>Artist:</b> %@<br><b>Composer:</b>%@<p>%@</p></body></html>", htmlStr, videoInfo.videoArtist, videoInfo.videoCompositor, videoInfo.videoDescription];
[self.myWebview loadHTMLString: embedHTML baseURL: nil];

if([appDelegate.lastState isEqualToString:@"play"])
{
    [appDelegate pausePlayer];
    manuallyPause = YES;
}

2
我也有同样的问题...通知 (UIMoviePlayerControllerWillExitFullscreenNotification, UIMoviePlayerControllerDidExitFullscreenNotification, MPMoviePlayerDidExitFullscreenNotification, MPMoviePlayerPlaybackDidFinishNotification) 在iOS 8上无法正常工作。在iOS 7上处理这些事件是没有问题的! - KepPM
更新:MPMoviePlayerDidExitFullscreenNotification和MPMoviePlayerPlaybackDidFinishNotification正常工作。 - KepPM
1个回答

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接