Fix race condition in Chrome (#547)

When the changeMedia frame loads a new Google Drive video, @yt is still
set from before and moreover @yt.ready is still true, so calling play()
can result in a TypeError if the new embed hasn't loaded yet (this
seemed to happen consistently in Chrome and I was unable to make it
happen in Firefox).
This commit is contained in:
calzoneman 2015-12-21 17:23:48 -08:00
parent 5a2ef2d24d
commit 04ffda7a20
2 changed files with 2 additions and 0 deletions

View file

@ -28,6 +28,7 @@ window.GoogleDriveYouTubePlayer = class GoogleDriveYouTubePlayer extends Player
@onReady() @onReady()
load: (data) -> load: (data) ->
@yt = null
@setMediaProperties(data) @setMediaProperties(data)
@init(data) @init(data)

View file

@ -1129,6 +1129,7 @@
}; };
GoogleDriveYouTubePlayer.prototype.load = function(data) { GoogleDriveYouTubePlayer.prototype.load = function(data) {
this.yt = null;
this.setMediaProperties(data); this.setMediaProperties(data);
return this.init(data); return this.init(data);
}; };