mirror of
https://github.com/markuryy/shark.git
synced 2025-12-12 11:41:02 +00:00
fix: volume slider
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
|
||||
function handleVolumeChange(volume: number) {
|
||||
playback.setVolume(volume);
|
||||
audioPlayer.setVolume(volume);
|
||||
}
|
||||
|
||||
function formatTime(seconds: number): string {
|
||||
|
||||
@@ -137,9 +137,10 @@ export const audioPlayer = new AudioPlayer();
|
||||
if (typeof window !== 'undefined') {
|
||||
let prevTrack: Track | null = null;
|
||||
let prevIsPlaying = false;
|
||||
let prevVolume = 1;
|
||||
|
||||
playback.subscribe(state => {
|
||||
const { currentTrack, isPlaying } = state;
|
||||
const { currentTrack, isPlaying, volume } = state;
|
||||
|
||||
// Track changed
|
||||
if (currentTrack && currentTrack !== prevTrack) {
|
||||
@@ -160,5 +161,11 @@ if (typeof window !== 'undefined') {
|
||||
}
|
||||
prevIsPlaying = isPlaying;
|
||||
}
|
||||
|
||||
// Volume changed
|
||||
if (volume !== prevVolume) {
|
||||
audioPlayer.setVolume(volume);
|
||||
prevVolume = volume;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user