Javascript onYouTubePlayerReady回调未触发

Javascript onYouTubePlayerReady回调未触发,javascript,youtube,callback,Javascript,Youtube,Callback,根据 使用url调用嵌入应该在视频准备就绪时触发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=ytplay

根据

使用url调用嵌入应该在视频准备就绪时触发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>
但是回调没有被触发,请参见js fiddle:我做错了什么


要测试这些调用中的任何一个,您必须让您的文件在Web服务器上运行,因为Flash player限制本地文件和internet之间的调用。这可能是因为它位于iframe中。您需要此页面上的swobject。执行此操作时,请不要忘记allowScriptAccess。它看起来是重复的,请参考此链接嗨,您只需要自动播放视频就可以了。
function onYouTubePlayerReady(playerID){
    console.log(playerID);
    console.log('working');
    alert('working');
}