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.
This commit is contained in:
George Ogata
2015-05-24 03:21:28 -04:00
parent 5c4c9eb53e
commit 7031049819

View File

@@ -46,6 +46,8 @@ chrome.extension.sendMessage({}, function(response) {
target.addEventListener('ratechange', function(event) { target.addEventListener('ratechange', function(event) {
var speed = this.getSpeed(); var speed = this.getSpeed();
this.speedIndicator.textContent = speed; this.speedIndicator.textContent = speed;
tc.settings.speed = speed;
chrome.storage.sync.set({'speed': speed});
}.bind(this)); }.bind(this));
target.playbackRate = tc.settings.speed; target.playbackRate = tc.settings.speed;
@@ -126,8 +128,6 @@ chrome.extension.sendMessage({}, function(response) {
function setSpeed(v, speed) { function setSpeed(v, speed) {
v.playbackRate = speed; v.playbackRate = speed;
tc.settings.speed = speed;
chrome.storage.sync.set({'speed': speed});
} }
function runAction(action) { function runAction(action) {