Youtube iframe api: 'onReady', 'onStat

2019-07-19 08:08发布

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")}
      }
   });

},

/* [...] */

}

标签: youtube-api
2条回答
该账号已被封号
2楼-- · 2019-07-19 08:14

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

查看更多
可以哭但决不认输i
3楼-- · 2019-07-19 08:32

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

查看更多
登录 后发表回答