更新依赖

This commit is contained in:
lyswhut
2024-03-11 21:58:02 +08:00
parent 45fc8c77b6
commit 53245e9e4f
4 changed files with 864 additions and 203 deletions
+8 -5
View File
@@ -1,4 +1,7 @@
let audio: HTMLAudioElement | null = null
interface HTMLAudioElementChrome extends HTMLAudioElement {
setSinkId: (id: string) => Promise<void>
}
let audio: HTMLAudioElementChrome | null = null
let audioContext: AudioContext
let mediaSource: MediaElementAudioSourceNode
let analyser: AnalyserNode
@@ -56,7 +59,7 @@ export const soundR = 0.5
export const createAudio = () => {
if (audio) return
audio = new window.Audio()
audio = new window.Audio() as HTMLAudioElementChrome
audio.controls = false
audio.autoplay = true
audio.preload = 'auto'
@@ -372,9 +375,9 @@ export const setCurrentTime = (time: number) => {
if (audio) audio.currentTime = time
}
export const setMediaDeviceId = (mediaDeviceId: string) => {
// @ts-expect-error
return audio ? audio.setSinkId(mediaDeviceId) : Promise.resolve()
export const setMediaDeviceId = async(mediaDeviceId: string): Promise<void> => {
if (!audio) return
return audio.setSinkId(mediaDeviceId)
}
export const setVolume = (volume: number) => {