fix(studio): add preview audio mute controls (#853)

This commit is contained in:
Miguel Ángel
2026-05-15 03:37:53 +02:00
committed by GitHub
parent 9cc09fca83
commit d1e5ac2939
11 changed files with 338 additions and 27 deletions
@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import { resolveSeekPercent } from "./PlayerControls";
import { shouldMutePreviewAudio } from "../lib/timelineIframeHelpers";
describe("resolveSeekPercent", () => {
it("returns 0 when the track width is invalid", () => {
@@ -18,3 +19,19 @@ describe("resolveSeekPercent", () => {
expect(resolveSeekPercent(150, 100, 200)).toBe(0.25);
});
});
describe("shouldMutePreviewAudio", () => {
it("mutes when the user toggled audio off", () => {
expect(shouldMutePreviewAudio(true, 1)).toBe(true);
});
it("auto-mutes above 1x playback", () => {
expect(shouldMutePreviewAudio(false, 1.5)).toBe(true);
expect(shouldMutePreviewAudio(false, 2)).toBe(true);
});
it("keeps audio on at 1x or slower when the user has not muted it", () => {
expect(shouldMutePreviewAudio(false, 1)).toBe(false);
expect(shouldMutePreviewAudio(false, 0.5)).toBe(false);
});
});