ios - mpmovie player dideexitfulscreen 通知在 ios 中不起作用

标签 ios webview ios8 mpmovieplayer

我正在 WebView 中加载 YouTube 视频。由于我的应用程序是在线广播应用程序,因此广播在后台播放。当我单击 webview 时,它会在 mpmovieplayer 中以全屏模式重定向视频。我想要的是当有人点击 webview 或 mpmovieplayer 开始播放视频时, radio 应该暂停。但是我如何跟踪 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;
}

最佳答案

查看答案 https://stackoverflow.com/a/26263803/1756448 (来自 user1717750)和 https://stackoverflow.com/a/26096400/1756448 (作者塞尔文)。

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

对我有用! )

关于ios - mpmovie player dideexitfulscreen 通知在 ios 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25741643/

相关文章:

android - 字符串 webview 中的 html 标签 <div>

ios - 从 iOS 9 开始,我无法再获取无线 SSID : CNCopyCurrentNetworkInfo won't work

ios - 防止或检测从 iOS 8 键盘传递的事件

ios - 如何将按钮移动到随机位置? ( swift )

ios - 何时在应用程序 :performFetchWithCompletionHandler: when Background Fetch is async? 中调用 completionHandler

ios - Objective-C 对象放置 iPad

android - react native : Webview getUserMedia not working (onPermissionRequest override? )

iphone - UISegmentedControl 颜色问题 - 颜色在模拟器上显示正常,而不是在设备上

java - Android Webview 页面无法正确加载页面

ios8 - Xcode 6 GM 与 iPhone 5s (iOS 8 GM) - 0xE8000070