大佬教程收集整理的这篇文章主要介绍了ios – UIWebview中的Youtube视频自动播放,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我找到了两种在UIWebView中嵌入youtube视频的方法
1)
NSString *youTubeHTMLTemplate = @"<html><head><style type=\"text/css\">body { BACkground-color: transparent;color: white;}</style></head><body style=\"margin:0\"><embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" width=\"%0.0f\" height=\"%0.0f\"></embed></body></html>"; finalHtml = [NSString StringWithFormat:youTubeHTMLTemplate,fullYopuTubeUrl,htmlFrameWidth,htmlFrameHeight];
2)
NSString *youTubeHTMLTemplate = @"<html><body style=\"margin:0;padding:0;\"><iframe class=\"youtube-player\" type=\"text/html\" width=\"%f\" height=\"%f\" src=\"http://www.youtube.com/embed/%@\" frameborder=\"0\" allowfullscreen></iframe></body></html>"; finalHtml = [NSString StringWithFormat:youTubeHTMLTemplate,htmlFrameHeight,videoID];
如果我使用(1)方法并遵循给出here我的视频自动播放的方法.想法是在UIWebView中找到按钮并向其发送触摸事件.
我认为建议使用(2)方法,因为(1)仅用于Flash视频(对吗?).
无论如何(2)是可能的吗?这个link说没有.
谁能证实
A.截至目前,无法进行自动播放.
更新:我可以使用Youtube JS API自动播放youtube视频,请参阅https://developers.google.com/youtube/js_api_reference
只需从onPlayerReady调用playVideo即可
function onPlayerReady(event) { event.target.playVideo(); }
以上是大佬教程为你收集整理的ios – UIWebview中的Youtube视频自动播放全部内容,希望文章能够帮你解决ios – UIWebview中的Youtube视频自动播放所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。