player/youtube: remove setQuality logic due to #726

This commit is contained in:
Calvin Montgomery 2021-07-25 20:43:15 -07:00
parent a3c17ea8ea
commit bce5d0d878
1 changed files with 4 additions and 27 deletions

View File

@ -4,7 +4,6 @@ window.YouTubePlayer = class YouTubePlayer extends Player
return new YouTubePlayer(data) return new YouTubePlayer(data)
@setMediaProperties(data) @setMediaProperties(data)
@qualityRaceCondition = true
@pauseSeekRaceCondition = false @pauseSeekRaceCondition = false
waitUntilDefined(window, 'YT', => waitUntilDefined(window, 'YT', =>
@ -34,9 +33,6 @@ window.YouTubePlayer = class YouTubePlayer extends Player
@setMediaProperties(data) @setMediaProperties(data)
if @yt and @yt.ready if @yt and @yt.ready
@yt.loadVideoById(data.id, data.currentTime) @yt.loadVideoById(data.id, data.currentTime)
@qualityRaceCondition = true
if USEROPTS.default_quality
@setQuality(USEROPTS.default_quality)
else else
console.error('WTF? YouTubePlayer::load() called but yt is not ready') console.error('WTF? YouTubePlayer::load() called but yt is not ready')
@ -45,15 +41,9 @@ window.YouTubePlayer = class YouTubePlayer extends Player
@setVolume(VOLUME) @setVolume(VOLUME)
onStateChange: (ev) -> onStateChange: (ev) ->
# For some reason setting the quality doesn't work # If you pause the video before the first PLAYING
# until the first event has fired. # event is emitted, weird things happen (or at least that was true
if @qualityRaceCondition # whenever this comment was authored in 2015).
@qualityRaceCondition = false
if USEROPTS.default_quality
@setQuality(USEROPTS.default_quality)
# Similar to above, if you pause the video before the first PLAYING
# event is emitted, weird things happen.
if ev.data == YT.PlayerState.PLAYING and @pauseSeekRaceCondition if ev.data == YT.PlayerState.PLAYING and @pauseSeekRaceCondition
@pause() @pause()
@pauseSeekRaceCondition = false @pauseSeekRaceCondition = false
@ -90,20 +80,7 @@ window.YouTubePlayer = class YouTubePlayer extends Player
@yt.setVolume(volume * 100) @yt.setVolume(volume * 100)
setQuality: (quality) -> setQuality: (quality) ->
if not @yt or not @yt.ready # https://github.com/calzoneman/sync/issues/726
return
ytQuality = switch String(quality)
when '240' then 'small'
when '360' then 'medium'
when '480' then 'large'
when '720' then 'hd720'
when '1080' then 'hd1080'
when 'best' then 'highres'
else 'auto'
if ytQuality != 'auto'
@yt.setPlaybackQuality(ytQuality)
getTime: (cb) -> getTime: (cb) ->
if @yt and @yt.ready if @yt and @yt.ready