为什么视频无法加载?我应该如何加载和播放视频上的无铬播放器


 <html>
 <body>
 <div id="ytplayer_div1">You need Flash player 8 or higher to view this content.</div>
 <script type='text/javascript' src='swfobject.js'> </script>
 <script type='text/javascript'>
 swfobject.embedSWF
 (
    'http://www.youtube.com/apiplayer?enablejsapi=1',
    'ytplayer_div1',
'425',
'344',
'8',
null,
null,
{
    allowScriptAccess: 'always',
            allowFullScreen: 'true'
},
{
    id: 'ytplayer_object'
}
);
var ytplayer = document.getElementById("ytplayer_div1");
ytplayer.loadVideoById("bHQqvYy5KYo", 5, "large");
</script>
</body>
</html>

Javascript Player API: Getting Started,

当播放器准备好时,API将调用onYouTubePlayerReady回调函数。

包装

var ytplayer = document.getElementById("ytplayer_div1");
ytplayer.loadVideoById("bHQqvYy5KYo", 5, "large");

onYouTubePlayerReady = function() {
  var ytplayer = document.getElementById("ytplayer_object");
  ytplayer.loadVideoById("bHQqvYy5KYo", 5, "large");
}

注意document.getElementById("ytplayer_object"),其中id必须等于这里传递给swfobject.embedSWFid属性:

{
    id: 'ytplayer_object'
}

相关内容

  • 没有找到相关文章