【问题标题】:Youtube Api with listener for state change带有状态变化监听器的 Youtube Api
【发布时间】:2012-05-30 08:13:04
【问题描述】:

我正在测试 Youtube API,但状态监听器在演示中不起作用,我不明白为什么?

这是演示的简单代码:

    <script src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" type="text/javascript"></script>
<script type="text/javascript">
    var params = { allowScriptAccess: "always" };
    var atts = { id: "myytplayer" };
    swfobject.embedSWF("http://www.youtube.com/v/u1zgFlCw8Aw?enablejsapi=1&playerapiid=ytplayer&version=3",
                       "ytapiplayer", "425", "356", "8", null, null, params, atts);
    function onYouTubePlayerReady(playerId) {
      ytplayer = document.getElementById("myytplayer");
      ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
    }
    function onytplayerStateChange(newState) {
       alert("Player's new state: " + newState);
    }
</script><div id="ytapiplayer">
You need Flash player 8+ and JavaScript enabled to view this video.  </div>

【问题讨论】:

  • 不工作,因为我已经在我的本地计算机上测试了这个演示。

标签: api youtube listener


【解决方案1】:

你是在本地电脑上测试吗?

尝试在网站上测试并使用前缀 http:// 访问它

编辑: 你已经解决了。抱歉,我发帖后才知道。

【讨论】:

    猜你喜欢
    • 2021-02-17
    • 1970-01-01
    • 2019-08-10
    • 2017-05-31
    • 1970-01-01
    • 1970-01-01
    • 2021-06-16
    • 2011-01-31
    • 1970-01-01
    相关资源
    最近更新 更多