add PlayBackShortcuts.plugin.js

This commit is contained in:
akstasy 2026-04-11 22:10:49 +00:00
parent a709640332
commit 013042b44c

View File

@ -0,0 +1,38 @@
/**
* @name PlayBackShortcuts
* @description Adds hotkeys for changing playback speed. "{" (To decrease playback speed) and "}" (To increase playback speed).
* @updateUrl https://git.ofoxer.com/akstasy/stremio-playback-shortcuts/raw/branch/main/PlayBackShortcuts.plugin.js
* @version 1.0.0
* @author akstasy
*/
window.addEventListener('popstate', () => {
let playbackSpeedMenu = document.getElementById("playbackSpeedMenu")
if(!playbackSpeedMenu) return;
let scope = angular.element(playbackSpeedMenu).scope();
let availableRates = scope.rates;
document.addEventListener("keyup", (e) => {
if(e.key === '{') {
let currentRate = scope.currentRate;
let index = availableRates.indexOf(currentRate);
if((availableRates.length - 1) != index) {
let newPlaybackSpeed = scope.rates[index + 1];
console.log(`[ PlayBackShortcuts ] Decreasing playback speed to ${newPlaybackSpeed}`)
scope.changeSpeed(newPlaybackSpeed);
}
} else if(e.key === '}') {
let currentRate = scope.currentRate;
let index = availableRates.indexOf(currentRate);
if(availableRates[0] != currentRate) {
let newPlaybackSpeed = scope.rates[index - 1];
console.log(`[ PlayBackShortcuts ] Increasing playback speed to ${newPlaybackSpeed}`);
scope.changeSpeed(scope.rates[index - 1]);
}
}
})
});