mpmovieplayer没有在ios中工作的exitfullscreen通知

时间:2014-09-09 09:55:10

标签: ios webview ios8 mpmovieplayer

我正在网页浏览中加载YouTube视频。由于我的应用程序是一个在线广播应用程序,收音机在后台播放。当我点击webview时,它会在mpmovieplayer中以全屏模式重定向视频。我想要的是当有人点击webview或当mpmovieplayer开始播放视频时,收音机应该暂停。但是我如何跟踪mpmoviepayer何时开始播放和退出完整的scrren。我还在我的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;
}

1 个答案:

答案 0 :(得分:0)

查看答案https://stackoverflow.com/a/26263803/1756448 user1717750 )和https://stackoverflow.com/a/26096400/1756448 Selvin )。

将AVPlayerItemBecameCurrentNotification与用于iOS 8的UIWindowDidBecomeVisibleNotification和UIWindowDidBecomeHiddenNotification结合使用 而不是UIMoviePlayerControllerDidExitFullscreenNotification。

对我有用! )