我试图在Swift的UIWebView中播放YouTube视频,当视频全屏显示时,我在标题上显示一条消息并且播放按钮未显示,我尝试了所有内容并尝试了使用谷歌的YTPlayerView,但问题是同样的,请帮我解决这个问题。
这是代码:
let htmlString = "<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){}</script><iframe
id='playerId' type='text/html' width='\(UIScreen.mainScreen().bounds.width)' height='\(self.imageCollectionView.frame.height)' src='\(url!.description)?enablejsapi=1&rel=0&playsinline=1&autoplay=1' frameborder='0'></body></html>"
cell.vedioWebPage.allowsInlineMediaPlayback = true
cell.vedioWebPage.mediaPlaybackRequiresUserAction = false
cell.vedioWebPage.loadHTMLString(htmlString, baseURL: NSBundle.mainBundle().resourceURL)
这是截图: