mirror of
https://github.com/SoPat712/videospeed.git
synced 2025-08-22 02:18:45 -04:00
Let each controller can track its own speed (#463)
Prevent source changes from changing speed in same video container.
This commit is contained in:

committed by
Ilya Grigorik

parent
4b112362f4
commit
3c133810b9
@@ -110,10 +110,11 @@
|
||||
this.parent = target.parentElement || parent;
|
||||
this.document = target.ownerDocument;
|
||||
this.id = Math.random().toString(36).substr(2, 9);
|
||||
this.speed = 1.0;
|
||||
|
||||
if (!tc.settings.rememberSpeed) {
|
||||
if (!tc.settings.speeds[target.src]) {
|
||||
tc.settings.speeds[target.src] = 1.0;
|
||||
tc.settings.speeds[target.src] = this.speed;
|
||||
}
|
||||
setKeyBindings("reset", getKeyBindings("fast")); // resetSpeed = fastSpeed
|
||||
} else {
|
||||
@@ -124,14 +125,14 @@
|
||||
target.addEventListener('play', function(event) {
|
||||
if (!tc.settings.rememberSpeed) {
|
||||
if (!tc.settings.speeds[target.src]) {
|
||||
tc.settings.speeds[target.src] = 1.0;
|
||||
tc.settings.speeds[target.src] = this.speed;
|
||||
}
|
||||
setKeyBindings("reset", getKeyBindings("fast")); // resetSpeed = fastSpeed
|
||||
} else {
|
||||
tc.settings.speeds[target.src] = tc.settings.lastSpeed;
|
||||
}
|
||||
target.playbackRate = tc.settings.speeds[target.src];
|
||||
});
|
||||
}.bind(this));
|
||||
|
||||
target.addEventListener('ratechange', function(event) {
|
||||
// Ignore ratechange events on unitialized videos.
|
||||
@@ -141,6 +142,7 @@
|
||||
this.speedIndicator.textContent = speed;
|
||||
tc.settings.speeds[this.video.src] = speed;
|
||||
tc.settings.lastSpeed = speed;
|
||||
this.speed = speed;
|
||||
chrome.storage.sync.set({'lastSpeed': speed}, function() {
|
||||
console.log('Speed setting saved: ' + speed);
|
||||
});
|
||||
|
Reference in New Issue
Block a user