在Swift 2.0中播放视频时如何避免全屏?
let Code:NSString = "<iframe width=255 height=135 src=http://www.youtube.com/embed/eVk3TMB1JWY?autoplay=1&fs=0 frameborder=0 allowfullscreen=false></>"
我都尝试过fs = 0和allowfullscreen = false但是都没有工作。
当视频显示在我的网页视图中时,还会显示有关该视频的信息;我怎么能避免这种情况呢?
答案 0 :(得分:0)
根据您的描述,听起来您想播放视频&#34;内联。&#34;将您想要的任何宽度和高度值传递到UIWebView构造函数中,以允许inLine播放,而不会将视频弹出打开到其全屏播放器。
let webView = UIWebView(frame: self.view.frame) // or your custom CGRect
self.view.addSubview(webView)
self.view.bringSubviewToFront(webView)
webView.allowsInlineMediaPlayback = true
webView.mediaPlaybackRequiresUserAction = false
let videoID = "zN-GGeNPQEg" // https://www.youtube.com/watch?v=zN-GGeNPQEg
let 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='\(self.view.frame.size.height)' src='http://www.youtube.com/embed/\(videoID)?enablejsapi=1&rel=0&playsinline=1&autoplay=1' frameborder='0'></body></html>"
webView.loadHTMLString(embededHTML, baseURL: NSBundle.mainBundle().resourceURL)
答案 1 :(得分:0)
您只需要从链接中删除allowfullscreen。您的链接将如下所示:
http://www.youtube.com/embed/eVk3TMB1JWY?autoplay=1&fs=0 frameborder = 0&gt;