Fix #799 and remove old unused quality selection

This commit is contained in:
Calvin Montgomery 2019-03-27 21:19:30 -07:00
parent b25560c4a9
commit 8c136c563a
3 changed files with 6 additions and 28 deletions

View file

@ -2,7 +2,7 @@
"author": "Calvin Montgomery", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "3.63.4", "version": "3.63.5",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View file

@ -59,6 +59,7 @@ window.handleMediaUpdate = (data) ->
if data.currentTime < 0 if data.currentTime < 0
data.currentTime = 0 data.currentTime = 0
PLAYER.load(data) PLAYER.load(data)
if not waiting
PLAYER.play() PLAYER.play()
if waiting if waiting

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', =>
@ -18,7 +17,8 @@ window.YouTubePlayer = class YouTubePlayer extends Player
videoId: data.id videoId: data.id
playerVars: playerVars:
autohide: 1 autohide: 1
autoplay: 1 autoplay: if data.currentTime > 0 then 1 else 0
start: if data.currentTime > 0 then Math.round(data.currentTime) else 0
controls: 1 controls: 1
iv_load_policy: 3 # iv_load_policy 3 indicates no annotations iv_load_policy: 3 # iv_load_policy 3 indicates no annotations
rel: 0 rel: 0
@ -34,9 +34,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,13 +42,6 @@ window.YouTubePlayer = class YouTubePlayer extends Player
@setVolume(VOLUME) @setVolume(VOLUME)
onStateChange: (ev) -> onStateChange: (ev) ->
# For some reason setting the quality doesn't work
# until the first event has fired.
if @qualityRaceCondition
@qualityRaceCondition = false
if USEROPTS.default_quality
@setQuality(USEROPTS.default_quality)
# Similar to above, if you pause the video before the first PLAYING # Similar to above, if you pause the video before the first PLAYING
# event is emitted, weird things happen. # event is emitted, weird things happen.
if ev.data == YT.PlayerState.PLAYING and @pauseSeekRaceCondition if ev.data == YT.PlayerState.PLAYING and @pauseSeekRaceCondition
@ -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 # YouTube no longer supports this
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