Skip to content
Snippets Groups Projects
Verified Commit ff4c02d7 authored by Dorian Koch's avatar Dorian Koch
Browse files

Change playback speed with click on current speed, closes #49

parent 8464c04f
Branches
Tags
No related merge requests found
Pipeline #6434 passed
...@@ -46,6 +46,28 @@ function initPlayer( ...@@ -46,6 +46,28 @@ function initPlayer(
player player
.getChild("ControlBar")! .getChild("ControlBar")!
.addChild("QualitySelector", {}, player.getChild("ControlBar")!.children().length - 1); .addChild("QualitySelector", {}, player.getChild("ControlBar")!.children().length - 1);
const changeRate = (dir: number) => {
return (e: any) => {
e.preventDefault();
const rates = player.playbackRates();
const currentRate = player.playbackRate() ?? 1;
const currentIndex = rates.indexOf(currentRate);
if (currentIndex === -1) return;
const newIndex =
(((currentIndex + dir) % rates.length) + rates.length) % rates.length; // modulo that works with negative numbers
player.playbackRate(rates[newIndex]);
};
};
player
.getChild("ControlBar")!
.getChild("PlaybackRateMenuButton")!
.on("click", changeRate(1));
// right click
player
.getChild("ControlBar")!
.getChild("PlaybackRateMenuButton")!
.on("contextmenu", changeRate(-1));
} }
let sources = media_sources.map((source) => { let sources = media_sources.map((source) => {
return { return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment