player: support toggle mute again
This commit is contained in:
parent
f102d87456
commit
1b8fd50d45
@ -24,15 +24,15 @@
|
|||||||
<div id="app-settings">
|
<div id="app-settings">
|
||||||
<div
|
<div
|
||||||
class="wrap"
|
class="wrap"
|
||||||
:class="{ buffering: player.isBuffering }">
|
:class="{ buffering: getBuffering }">
|
||||||
<button
|
<button
|
||||||
class="player"
|
class="player"
|
||||||
:class="player.isPlaying ? 'pause' : 'play'"
|
:class="getPlaying ? 'pause' : 'play'"
|
||||||
@click="togglePlay" />
|
@click="togglePlay" />
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="volumeIcon"
|
class="volumeIcon"
|
||||||
:class="player.volume == 0 ? 'volumeMute' : 'volumeFull'"
|
:class="getVolume == 0 ? 'volumeMute' : 'volumeFull'"
|
||||||
@click="toggleMute" />
|
@click="toggleMute" />
|
||||||
<input
|
<input
|
||||||
class="volume"
|
class="volume"
|
||||||
@ -41,31 +41,32 @@
|
|||||||
min="0"
|
min="0"
|
||||||
max="1"
|
max="1"
|
||||||
step=".05"
|
step=".05"
|
||||||
:value="player.volume"
|
:value="getVolume"
|
||||||
@input="setVolume($event)">
|
@input="setVolume($event.target.value)">
|
||||||
<div class="playerMetadata">
|
<div class="playerMetadata">
|
||||||
{{ player.title }}
|
{{ getTitle }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapGetters, mapActions } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
player() {
|
...mapGetters([
|
||||||
return this.$store.state.player
|
'getVolume',
|
||||||
},
|
'getBuffering',
|
||||||
|
'getPlaying',
|
||||||
|
'getTitle',
|
||||||
|
]),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setVolume() {
|
...mapActions([
|
||||||
this.$store.dispatch('setVolume', event.target.value)
|
'toggleMute',
|
||||||
},
|
'setVolume',
|
||||||
toggleMute() {
|
'togglePlay',
|
||||||
this.$store.dispatch('toggleMute')
|
]),
|
||||||
},
|
|
||||||
togglePlay() {
|
|
||||||
this.$store.dispatch('togglePlay')
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -33,6 +33,20 @@ export default ({
|
|||||||
oldVolume: localStorage.getItem('radio.volume') || 0.5,
|
oldVolume: localStorage.getItem('radio.volume') || 0.5,
|
||||||
title: '',
|
title: '',
|
||||||
},
|
},
|
||||||
|
getters: {
|
||||||
|
getPlaying: state => {
|
||||||
|
return state.isPlaying
|
||||||
|
},
|
||||||
|
getBuffering: state => {
|
||||||
|
return state.isBuffering
|
||||||
|
},
|
||||||
|
getVolume: state => {
|
||||||
|
return state.volume
|
||||||
|
},
|
||||||
|
getTitle: state => {
|
||||||
|
return state.title
|
||||||
|
},
|
||||||
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setPlaying(state, playerState) {
|
setPlaying(state, playerState) {
|
||||||
state.isPlaying = playerState
|
state.isPlaying = playerState
|
||||||
@ -46,16 +60,18 @@ export default ({
|
|||||||
setVolume(state, volume) {
|
setVolume(state, volume) {
|
||||||
state.volume = volume
|
state.volume = volume
|
||||||
localStorage.setItem('radio.volume', volume)
|
localStorage.setItem('radio.volume', volume)
|
||||||
|
player.setVolume(state.volume)
|
||||||
},
|
},
|
||||||
toggleMute(state) {
|
toggleMute(state) {
|
||||||
if (state.isMute) {
|
if (state.isMute) {
|
||||||
state.volume = state.player.oldVolume
|
state.volume = state.oldVolume
|
||||||
state.isMute = false
|
state.isMute = false
|
||||||
} else {
|
} else {
|
||||||
state.oldVolume = state.player.volume
|
state.oldVolume = state.volume
|
||||||
state.volume = 0
|
state.volume = 0
|
||||||
state.isMute = true
|
state.isMute = true
|
||||||
}
|
}
|
||||||
|
player.setVolume(state.volume)
|
||||||
},
|
},
|
||||||
togglePlay(state) {
|
togglePlay(state) {
|
||||||
if (state.isPlaying) {
|
if (state.isPlaying) {
|
||||||
|
Loading…
Reference in New Issue
Block a user