refactor: replace wavesurfer with html audio player
This commit is contained in:
6 files changed
+187
-94
No files matched your search
@@ -2,17 +2,30 @@ import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { create } from "zustand";
|
||||
import { setQueue } from "./queue";
|
||||
|
||||
import type React from "react";
|
||||
import { secToTicks } from "../date/time";
|
||||
|
||||
type AudioPlaybackStore = {
|
||||
display: boolean;
|
||||
url: string;
|
||||
item: BaseItemDto | undefined | null;
|
||||
playlistItemId: string | undefined;
|
||||
player: {
|
||||
currentTick: number;
|
||||
playing: boolean;
|
||||
ref: React.Ref<HTMLAudioElement> | null;
|
||||
};
|
||||
};
|
||||
export const useAudioPlayback = create<AudioPlaybackStore>(() => ({
|
||||
display: false,
|
||||
url: "",
|
||||
item: undefined,
|
||||
playlistItemId: undefined,
|
||||
player: {
|
||||
currentTick: 0,
|
||||
playing: false,
|
||||
ref: null,
|
||||
},
|
||||
}));
|
||||
|
||||
export const playAudio = (
|
||||
@@ -43,4 +56,16 @@ export const generateAudioStreamUrl = (
|
||||
};
|
||||
const urlParams = new URLSearchParams(urlOptions).toString();
|
||||
return `${basePath}/Audio/${itemId}/universal?${urlParams}`;
|
||||
};
|
||||
|
||||
export const setAudioRef = (ref) => {
|
||||
const state = useAudioPlayback.getState();
|
||||
state.player.ref = ref;
|
||||
useAudioPlayback.setState(state);
|
||||
};
|
||||
|
||||
export const setProgress = (ticks: number) => {
|
||||
const state = useAudioPlayback.getState();
|
||||
state.player.currentTick = ticks;
|
||||
useAudioPlayback.setState(state);
|
||||
};
|
||||
Reference in new issue
Block a user