From dfb7177a6d926476c03425acaeabc29c2bf1e177 Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Sat, 2 Feb 2019 15:56:20 -0800 Subject: [PATCH] Add workaround for Dailymotion issue --- player/dailymotion.coffee | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/player/dailymotion.coffee b/player/dailymotion.coffee index 58b0c035..9a8bc1f4 100644 --- a/player/dailymotion.coffee +++ b/player/dailymotion.coffee @@ -27,6 +27,7 @@ window.DailymotionPlayer = class DailymotionPlayer extends Player @dm.addEventListener('apiready', => @dm.ready = true + @dm.apiready = true @dm.addEventListener('ended', -> if CLIENT.leader socket.emit('playNext') @@ -47,12 +48,24 @@ window.DailymotionPlayer = class DailymotionPlayer extends Player @setVolume(VOLUME) @initialVolumeSet = true ) + + # Once the video stops, the internal state of the player + # becomes unusable and attempting to load() will corrupt it and + # crash the player with an error. As a short–medium term + # workaround, mark the player as "not ready" until the next + # video loads + @dm.addEventListener('video_end', => + @dm.ready = false + ) + @dm.addEventListener('playback_ready', => + @dm.ready = true + ) ) ) load: (data) -> @setMediaProperties(data) - if @dm and @dm.ready + if @dm and @dm.apiready @dm.load(data.id) @dm.seek(data.currentTime) else