我的嵌入式YouTube视频出现了一个奇怪的问题。所以我有一个webview。我加载了YouTube视频的网址。当我运行该应用程序时,一切都很好。Web视图将加载视频。但是,当我单击红色的播放按钮时。什么都没玩。视频无法开始。而且,当我单击视频标题时。如果可以这样说的话,它将带我进入真正的“ Youtube Player”。现在,如果我按了播放按钮,它将开始播放视频。
当我看到有关此的教程时,一切似乎都对他们很好。不适合我...需要帮助!我烦了....
这是处理此问题的代码部分:
@IBOutlet var webView: UIWebView!
func initilize()
{
let youtubeURL = "https://www.youtube.com/embed/Q0oIoR9mLwc"
webView.loadHTMLString("<iframe width=\"\(webView.frame.width)\" height=\"\(webView.frame.height)\" src=\"\(youtubeURL)\"?&inline=\"1\" frameborder=\"0\" allowfullscreen></iframe>", baseURL: nil)
}
编辑解决方案:看起来VeVo的音乐视频做到了!疯狂的 !!想知道为什么 ?!但是正如@MohanSingh所说的,这是URL链接。他还对视频的内联处理进行了一些修改。
@IBOutlet var webView: UIWebView!
func initilize()
{
let youtubeURL = "https://www.youtube.com/embed/JMEEdFz0d7Q"
webView.allowsInlineMediaPlayback = true
let width = webView.frame.width
let height = webView.frame.height
webView.loadHTMLString("<iframe width=\"\(width)\" height=\"\(height)\" src=\"\(youtubeURL)?&playsinline=1\" frameborder=\"0\" allowfullscreen></iframe>", baseURL: nil)
}
问候,
哈里
试试这个!webView.allowsInlineMediaPlayback = true
曾经在线播放视频。
@IBOutlet var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
initilize()
}
func initilize()
{
let youtubeURL = "https://www.youtube.com/embed/Q0oIoR9mLwc"
webView.allowsInlineMediaPlayback = true
let width = webView.frame.width
let height = webView.frame.height
webView.loadHTMLString("<iframe width=\"\(width)\" height=\"\(height)\" src=\"\(youtubeURL)?&playsinline=1\" frameborder=\"0\" allowfullscreen></iframe>", baseURL: nil)
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句