YouTube iframe api:“onReady”、“onStateChange”在 IE 8 中不触发

发布于 2024-12-01 11:43:28 字数 849 浏览 0 评论 0原文

我刚刚在 IE 8 中检查我的 YouTube 播放器,注意到“onReady”、“onStateChange”事件没有触发。正在调用 initPlayer 方法并播放视频,但事件未触发。

在 Safari、Firefox Mac、FireFox Win 上按预期工作。

我在这里错过了什么吗?

这是相关代码:

MyPlayer.prototype = {

/*   [...]  */


initPlayer: function () {

    var that = this;
    alert("initPlayer: (IE 8 gets this far)");

    this.player = new YT.Player(this.cfg.divTagId, {
        height:  this.cfg.height,
        width:   this.cfg.width,
        videoId: this.cfg.videoId,
        origin:  location.host,
        playerVars: {
           controls: this.cfg.controls, 
           wmode: 'opaque',
          fs: 0
       },
       events: {
         'onReady': function (event) {alert("onReady")},
         'onStateChange': function (event) {alert("onChange")}
      }
   });

},

/* [...] */

}

I just was checking my youtube player in IE 8 and noticed the 'onReady', 'onStateChange' events are not firing. The initPlayer method is being called and the video plays, but the events are not firing.

Works as expected on Safari, Firefox Mac, FireFox Win.

Am I missing something here?

Here is the relevant code:

MyPlayer.prototype = {

/*   [...]  */


initPlayer: function () {

    var that = this;
    alert("initPlayer: (IE 8 gets this far)");

    this.player = new YT.Player(this.cfg.divTagId, {
        height:  this.cfg.height,
        width:   this.cfg.width,
        videoId: this.cfg.videoId,
        origin:  location.host,
        playerVars: {
           controls: this.cfg.controls, 
           wmode: 'opaque',
          fs: 0
       },
       events: {
         'onReady': function (event) {alert("onReady")},
         'onStateChange': function (event) {alert("onChange")}
      }
   });

},

/* [...] */

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤寂小茶 2024-12-08 11:43:28

一个可能的因素是:如果您在本地运行 API,则该 API 将无法在 IE 中正常工作 - 尝试从 http: 路径运行您的代码。

来源:

http://groups.google.com/论坛/?fromgroups=#!topic/youtube-api-gdata/LV49fIR5Uo0

One possible factor: the API won't work properly in IE if you are running it locally - try running your code from an http: path.

Source:

http://groups.google.com/forum/?fromgroups=#!topic/youtube-api-gdata/LV49fIR5Uo0

你不是我要的菜∠ 2024-12-08 11:43:28

这是 YouTube API 代码中的一个老错误。此时一切应该都可以正常工作。

This was an old bug in the YouTube api code. It should all be working at this point.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文