Add workaround for Dailymotion issue

This commit is contained in:
Calvin Montgomery 2019-02-02 15:56:20 -08:00
parent 5c76eaf68a
commit dfb7177a6d

View file

@ -27,6 +27,7 @@ window.DailymotionPlayer = class DailymotionPlayer extends Player
@dm.addEventListener('apiready', => @dm.addEventListener('apiready', =>
@dm.ready = true @dm.ready = true
@dm.apiready = true
@dm.addEventListener('ended', -> @dm.addEventListener('ended', ->
if CLIENT.leader if CLIENT.leader
socket.emit('playNext') socket.emit('playNext')
@ -47,12 +48,24 @@ window.DailymotionPlayer = class DailymotionPlayer extends Player
@setVolume(VOLUME) @setVolume(VOLUME)
@initialVolumeSet = true @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 shortmedium 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) -> load: (data) ->
@setMediaProperties(data) @setMediaProperties(data)
if @dm and @dm.ready if @dm and @dm.apiready
@dm.load(data.id) @dm.load(data.id)
@dm.seek(data.currentTime) @dm.seek(data.currentTime)
else else