2022-10-30 23:13:57 +00:00
|
|
|
import { ref } from 'vue'
|
|
|
|
import { preferenceStore } from '@/stores'
|
|
|
|
|
|
|
|
export class VolumeManager {
|
|
|
|
private input!: HTMLInputElement
|
|
|
|
public volume = ref(0)
|
|
|
|
|
|
|
|
public init (input: HTMLInputElement) {
|
|
|
|
this.input = input
|
2022-11-02 14:06:53 +00:00
|
|
|
this.set(preferenceStore.volume)
|
2022-10-30 23:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public get () {
|
|
|
|
return this.volume.value
|
|
|
|
}
|
|
|
|
|
2024-01-23 22:50:50 +00:00
|
|
|
public set (volume: number) {
|
2022-10-30 23:13:57 +00:00
|
|
|
this.volume.value = volume
|
|
|
|
this.input.value = String(volume)
|
|
|
|
}
|
|
|
|
|
|
|
|
public mute () {
|
2024-01-23 22:50:50 +00:00
|
|
|
this.set(0)
|
2022-10-30 23:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public unmute () {
|
2022-11-02 14:06:53 +00:00
|
|
|
this.set(preferenceStore.volume)
|
2022-10-30 23:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const volumeManager = new VolumeManager()
|