feat(player): add speed control with popup menu and CSS theming (#241)

Add playback speed control to the player controls bar:
- Popup menu with logarithmic presets (0.25x-4x)
- Custom presets via speed-presets attribute
- Full CSS custom property theming (--hfp-accent, --hfp-controls-bg, etc.)
- ratechange event dispatch
- Exports: SPEED_PRESETS, formatSpeed, ControlsOptions
- Fix package.json export condition ordering
This commit is contained in:
Miguel Ángel
2026-04-10 20:47:12 +02:00
committed by GitHub
parent 9a3ed569a0
commit 0da93cea3d
5 changed files with 232 additions and 21 deletions
+25 -1
View File
@@ -1,5 +1,29 @@
import { describe, it, expect } from "vitest";
import { formatTime } from "./controls.js";
import { formatTime, formatSpeed, SPEED_PRESETS } from "./controls.js";
describe("SPEED_PRESETS", () => {
it("contains logarithmic speed steps", () => {
expect(SPEED_PRESETS).toEqual([0.25, 0.5, 1, 1.5, 2, 4]);
});
it("includes 1x as default speed", () => {
expect(SPEED_PRESETS).toContain(1);
});
});
describe("formatSpeed", () => {
it("formats integer speeds", () => {
expect(formatSpeed(1)).toBe("1x");
expect(formatSpeed(2)).toBe("2x");
expect(formatSpeed(4)).toBe("4x");
});
it("formats fractional speeds", () => {
expect(formatSpeed(0.25)).toBe("0.25x");
expect(formatSpeed(0.5)).toBe("0.5x");
expect(formatSpeed(1.5)).toBe("1.5x");
});
});
describe("formatTime", () => {
it("formats 0 seconds", () => {