Хранение значения preVol перед откл/вкл звука

This commit is contained in:
Norbaev 2024-06-30 00:18:11 +05:00
parent 2f9cf0307a
commit f6834ff973
1 changed files with 11 additions and 5 deletions

View File

@ -55,7 +55,13 @@
/> />
<q-skeleton v-if="loaderPlay" class="player__tools m--skeleton" /> <q-skeleton v-if="loaderPlay" class="player__tools m--skeleton" />
<div v-else class="player__volume"> <div v-else class="player__volume">
<span ref="volumeIcon" @click="toggleVolume" :class="volumeClass" /> <span
ref="volumeIcon"
@click="toggleVolume"
:class="
songVolume == 0 ? 'player__volume-off' : 'player__volume-on'
"
/>
<input <input
type="range" type="range"
min="0" min="0"
@ -106,6 +112,8 @@ export default {
connection: null, connection: null,
isUserMusic: !this.$store.state.currentPlay.live, isUserMusic: !this.$store.state.currentPlay.live,
songVolume: 0.5, songVolume: 0.5,
// Локальное значение для хранения громкости перед toggleVolume
preToggleVol: null,
playerInfo: { playerInfo: {
progress: 0, progress: 0,
currentTime: 0, currentTime: 0,
@ -129,9 +137,6 @@ export default {
loaderPlay() { loaderPlay() {
return this.$store.state.currentPlay.isLoader; return this.$store.state.currentPlay.isLoader;
}, },
volumeClass() {
return this.songVolume == 0 ? 'player__volume-off' : 'player__volume-on';
},
}, },
watch: { watch: {
currentPlay: { currentPlay: {
@ -381,10 +386,11 @@ export default {
}, },
toggleVolume() { toggleVolume() {
if (this.songVolume === 0) { if (this.songVolume === 0) {
this.songVolume = 1; this.songVolume = this.preToggleVol;
console.log(this.songVolume); console.log(this.songVolume);
this.$store.dispatch('handlerPlayer', { volume: this.songVolume }); this.$store.dispatch('handlerPlayer', { volume: this.songVolume });
} else { } else {
this.preToggleVol = this.songVolume;
this.songVolume = 0.0; this.songVolume = 0.0;
console.log(this.songVolume); console.log(this.songVolume);
this.$store.dispatch('handlerPlayer', { volume: this.songVolume }); this.$store.dispatch('handlerPlayer', { volume: this.songVolume });