我正在使用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;
}