调用带有网址http://www.youtube.com/v/VIDEO_ID?version=3&enablejsapi=1的嵌入应该在视频准备就绪时触发onYouTubePlayerReady()的回调。我试图像这样实现:
<body>
<iframe id="ytplayer" type="text/html" width="100%" height="56.25"
src="http://www.youtube.com/v/M7lc1UVf-VE?version=3&enablejsapi=1&playerapiid=ytplayer"
frameborder="0" allowfullscreen></iframe>
</body>
使用Javascript:
function onYouTubePlayerReady(playerID){
console.log(playerID);
console.log('working');
alert('working');
}
但是没有触发回调,请参阅js-fiddle:我做错了什么?