update: play audio + srt sync

This commit is contained in:
Tom Boullay
2026-05-10 00:07:56 +01:00
parent 8ef1da0e9a
commit 53fdf3cb1e
4 changed files with 100 additions and 6 deletions
+7 -1
View File
@@ -54,7 +54,11 @@ export class AudioManager {
return this._categoryVolumes[category];
}
playSound(path: string, volume = 1, options: PlaySoundOptions = {}): void {
playSound(
path: string,
volume = 1,
options: PlaySoundOptions = {},
): HTMLAudioElement {
const audio = this._acquireAudio(path);
const category = options.category ?? AudioManager.DEFAULT_SOUND_CATEGORY;
audio.volume = this._getEffectiveVolume(category, volume);
@@ -75,6 +79,8 @@ export class AudioManager {
error: AudioManager._toLogValue(error),
});
});
return audio;
}
playMusic(path: string, volume = 1): void {
+24
View File
@@ -0,0 +1,24 @@
import { create } from "zustand";
import type { DialogueSpeaker } from "@/types/dialogues/dialogues";
interface ActiveSubtitle {
speaker: DialogueSpeaker;
text: string;
}
interface SubtitleState {
activeSubtitle: ActiveSubtitle | null;
}
interface SubtitleActions {
setActiveSubtitle: (subtitle: ActiveSubtitle | null) => void;
clearActiveSubtitle: () => void;
}
type SubtitleStore = SubtitleState & SubtitleActions;
export const useSubtitleStore = create<SubtitleStore>()((set) => ({
activeSubtitle: null,
setActiveSubtitle: (activeSubtitle) => set({ activeSubtitle }),
clearActiveSubtitle: () => set({ activeSubtitle: null }),
}));