我想使用youTube视频网址播放youtube视频。
我在iOS版本5.1.1中成功播放了视频,但该视频无法在iOS版本5.0.1和4.0或更低版本中播放。我正在使用webview播放视频。
发布于 2012-10-05 18:44:25
对于低于5的IOS,您需要使用iframe:
NSString *youTubeVideoHTML = @"<iframe id=\"yt\" class=\"youtube-player\" type=\"text/html\" width=\"280\" height=\"186\" src=\"http://www.youtube.com/embed/xxxxxx\" frameborder=\"0\">";
and for ios 5 above we can use embed :
NSString *youTubeVideoHTML = @"<html><head>\
<body style=\"margin:0\">\
<embed id=\"yt\" src=\"http://www.youtube.com/watch?v=xxxxxx?autoplay=1\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";注意:在iOS6中,我发现只有当我们传递youtube的url为:http://www.youtube.com/v/xxxxxx?autoplay=1时,url才能起作用。
希望这能行得通。
发布于 2012-10-04 18:40:56
从你的评论看,你似乎使用了错误的嵌入代码,youtube嵌入现在看起来像这样
<iframe width="560" height="315" src="http://www.youtube.com/embed/Cw2RzvK13F4" frameborder="0" allowfullscreen></iframe>正如前面提到的,flash不能在iPhone上播放,所以它需要使用HTML5版本,不幸的是,我不认为100%的youtube视频已经被转换,但大多数应该可以工作。
发布于 2012-10-10 00:29:32
您需要确保对嵌入的视频使用正确的URL格式。他们最近对它做了一些改变。
Youtube Embedded Players and Player Parameters - YouTube - Google Developers
它看起来是这样的:
http://www.youtube.com/embed/VIDEO_IDhttps://stackoverflow.com/questions/12425307
复制相似问题