From 8c136c563a007afa931e89e7e1cf0098a514f078 Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Wed, 27 Mar 2019 21:19:30 -0700 Subject: [PATCH] Fix #799 and remove old unused quality selection --- package.json | 2 +- player/update.coffee | 3 ++- player/youtube.coffee | 29 +++-------------------------- 3 files changed, 6 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 51323fcc..f9e88296 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "3.63.4", + "version": "3.63.5", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/player/update.coffee b/player/update.coffee index f9104484..e7bb2ca6 100644 --- a/player/update.coffee +++ b/player/update.coffee @@ -59,7 +59,8 @@ window.handleMediaUpdate = (data) -> if data.currentTime < 0 data.currentTime = 0 PLAYER.load(data) - PLAYER.play() + if not waiting + PLAYER.play() if waiting PLAYER.seekTo(0) diff --git a/player/youtube.coffee b/player/youtube.coffee index 7c94f8a9..2a65de42 100644 --- a/player/youtube.coffee +++ b/player/youtube.coffee @@ -4,7 +4,6 @@ window.YouTubePlayer = class YouTubePlayer extends Player return new YouTubePlayer(data) @setMediaProperties(data) - @qualityRaceCondition = true @pauseSeekRaceCondition = false waitUntilDefined(window, 'YT', => @@ -18,7 +17,8 @@ window.YouTubePlayer = class YouTubePlayer extends Player videoId: data.id playerVars: 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 iv_load_policy: 3 # iv_load_policy 3 indicates no annotations rel: 0 @@ -34,9 +34,6 @@ window.YouTubePlayer = class YouTubePlayer extends Player @setMediaProperties(data) if @yt and @yt.ready @yt.loadVideoById(data.id, data.currentTime) - @qualityRaceCondition = true - if USEROPTS.default_quality - @setQuality(USEROPTS.default_quality) else console.error('WTF? YouTubePlayer::load() called but yt is not ready') @@ -45,13 +42,6 @@ window.YouTubePlayer = class YouTubePlayer extends Player @setVolume(VOLUME) 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 # event is emitted, weird things happen. if ev.data == YT.PlayerState.PLAYING and @pauseSeekRaceCondition @@ -90,20 +80,7 @@ window.YouTubePlayer = class YouTubePlayer extends Player @yt.setVolume(volume * 100) setQuality: (quality) -> - if not @yt or not @yt.ready - 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) + # YouTube no longer supports this getTime: (cb) -> if @yt and @yt.ready