From 703104981947ab3bdcec3ac947820ac6ae1b3aa3 Mon Sep 17 00:00:00 2001 From: George Ogata Date: Sun, 24 May 2015 03:21:28 -0400 Subject: [PATCH 1/2] Update our speed setting when the speed is changed externally. e.g. Coursera videos have their own speed controls. If the speed is changed from A to B via their controls, then the video is paused & resumed, our play callback would reset the speed to A. We now ensure our speed setting is accurate by updating it in the ratechange callback, which happens no matter how the speed is updated. --- inject.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inject.js b/inject.js index 62cc05f..e46d0f9 100644 --- a/inject.js +++ b/inject.js @@ -46,6 +46,8 @@ chrome.extension.sendMessage({}, function(response) { target.addEventListener('ratechange', function(event) { var speed = this.getSpeed(); this.speedIndicator.textContent = speed; + tc.settings.speed = speed; + chrome.storage.sync.set({'speed': speed}); }.bind(this)); target.playbackRate = tc.settings.speed; @@ -126,8 +128,6 @@ chrome.extension.sendMessage({}, function(response) { function setSpeed(v, speed) { v.playbackRate = speed; - tc.settings.speed = speed; - chrome.storage.sync.set({'speed': speed}); } function runAction(action) { From e75f4f0c6059c28093c07265e0bdee89f1593549 Mon Sep 17 00:00:00 2001 From: George Ogata Date: Sun, 31 May 2015 03:54:57 -0400 Subject: [PATCH 2/2] Don't update our video speed setting before the video is loaded. In this state, the playback rate is always 1, as we haven't had a chance to update it yet (which currently happens in the play callback). Fixes speed setting when jumping between YouTube videos. --- inject.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/inject.js b/inject.js index e46d0f9..5f32590 100644 --- a/inject.js +++ b/inject.js @@ -44,6 +44,9 @@ chrome.extension.sendMessage({}, function(response) { }); target.addEventListener('ratechange', function(event) { + if (target.readyState === 0) { + return; + } var speed = this.getSpeed(); this.speedIndicator.textContent = speed; tc.settings.speed = speed;