gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:38:33 26 4
gpt4 key购买 nike

我正在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com