From 04ffda7a209fead87bafa9fbd7fc8ec2effd0745 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Mon, 21 Dec 2015 17:23:48 -0800 Subject: [PATCH] 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). --- player/gdrive-youtube.coffee | 1 + www/js/player.js | 1 + 2 files changed, 2 insertions(+) diff --git a/player/gdrive-youtube.coffee b/player/gdrive-youtube.coffee index 37aa08a2..c7461c03 100644 --- a/player/gdrive-youtube.coffee +++ b/player/gdrive-youtube.coffee @@ -28,6 +28,7 @@ window.GoogleDriveYouTubePlayer = class GoogleDriveYouTubePlayer extends Player @onReady() load: (data) -> + @yt = null @setMediaProperties(data) @init(data) diff --git a/www/js/player.js b/www/js/player.js index 02c7a2fc..1cf52a40 100644 --- a/www/js/player.js +++ b/www/js/player.js @@ -1129,6 +1129,7 @@ }; GoogleDriveYouTubePlayer.prototype.load = function(data) { + this.yt = null; this.setMediaProperties(data); return this.init(data); };