我正在为 YouTube 使用 JS API 并显示视频播放器,use of embedSWF is recommended by Google in the documentation ,像这样:
<script type="text/javascript" src="swfobject.js"></script>
<div id="ytapiplayer">
You need Flash player 8+ and JavaScript enabled to view this video.
</div>
<script type="text/javascript">
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
swfobject.embedSWF("http://www.youtube.com/v/VIDEO_ID?enablejsapi=1&playerapiid=ytplayer&version=3","ytapiplayer", "425", "356", "8", null, null, params, atts);
</script>
虽然这在我的电脑和 Android 设备上运行良好,但在 iOS 上,ytapiplayer div 不会变成嵌入式播放器,而是只显示其原始内容,即错误消息说 Flash player 8+和 JS 是必需的。
我的这个可以在 iOS 上运行吗?如果是,怎么办?
提前致谢!
最佳答案
也许您应该尝试新的 YouTube iframe Player API? https://developers.google.com/youtube/iframe_api_reference
它适用于移动设备,无需考虑 Flash。 嵌入示例:
<script type="text/javascript" src="//www.youtube.com/iframe_api"></script>
function onYouTubePlayerAPIReady() {
var videoBox = document.getElementById('video1');
videoBox.ytplayer = new YT.Player(videoBox, {
videoId: 'kXDiGtgPL6E',
playerVars: {
//controls: 0,
wmode:'transparent'
},
height: '200',
width: '320'
});
}
关于javascript - 使 YouTube JS API 与 iOS 一起工作,处理 embedSWF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12799384/