gpt4 book ai didi

Swift 3. 从全屏退出时 AVPlayerViewController 问题

转载 作者:IT王子 更新时间:2023-10-29 05:21:56 34 4
gpt4 key购买 nike

当应用程序从全屏退出并且屏幕 UI 滑动到顶部时,我在控制台中收到错误消息。

错误:

-[AVPlayerViewController exitFullScreenAnimated:completionHandler:] 失败,错误 View needs be loaded before you can call -[AVPlayerViewController (0x1028b5000) exitFullScreenAnimated:completionHandler:]!

应用在 UIWebView 中以嵌入的 HTML 播放 youtube 视频。

代码:

var webView = UIWebView(frame: self.view.frame)
webView.allowsInlineMediaPlayback = true
webView.mediaPlaybackRequiresUserAction = false
embededHTML = "<html><body style='margin:0px;padding:0px;'><script type='text/javascript' src='http://www.youtube.com/iframe_api'></script><script type='text/javascript'>function onYouTubeIframeAPIReady(){ytplayer=new YT.Player('playerId',{events:{onReady:onPlayerReady}})}function onPlayerReady(a){a.target.playVideo();}</script><iframe id='playerId' type='text/html' width='\(self.view.frame.size.width)' height=\(frameHeight) src='http://www.youtube.com/embed/\(youtube_code)?enablejsapi=1&rel=0&playsinline=1&autoplay=1&showinfo=0&modestbranding=0' frameborder='0'></body></html>"

@IBAction func playVideo(_ sender: Any) {
if let webView = webView {
self.view.bringSubview(toFront: webView)
webView.scrollView.isScrollEnabled = false;
webView.scrollView.bounces = false;
// Load your webView with the HTML we just set up
webView.loadHTMLString(embededHTML, baseURL: Bundle.main.bundleURL)
}
}

非常感谢任何帮助。谢谢。

最佳答案

尝试用 WebKit 的 WKWebView 替换 UIWebView

关于Swift 3. 从全屏退出时 AVPlayerViewController 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50583312/

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