diff --git a/src/components/Player.vue b/src/components/Player.vue index 751d42b..6fff979 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -9,7 +9,8 @@
+ :class="player.volume == 0 ? 'volumeMute' : 'volumeVolume'" + @click="toggleMute" /> @@ -98,6 +102,7 @@ export default { position: relative; left: 85px; top: 20px; + cursor: pointer; } .volumeFull { diff --git a/src/store.js b/src/store.js index c6b729f..2a54d86 100644 --- a/src/store.js +++ b/src/store.js @@ -8,6 +8,8 @@ export default new Vuex.Store({ isPlaying: false, isBuffering: false, volume: 0, + isMute: false, + oldVolume: 0, }, }, mutations: { @@ -20,6 +22,14 @@ export default new Vuex.Store({ changeVolume(state, volume) { state.player.volume = volume }, + toggleMute(state) { + if (state.player.isMute) { + state.player.volume = state.player.oldVolume + } else { + state.player.oldVolume = state.player.volume + state.player.volume = 0 + } + }, }, actions: { isPlaying(context, playerState) { @@ -31,5 +41,8 @@ export default new Vuex.Store({ changeVolume(context, volume) { context.commit('changeVolume', volume) }, + toggleMute(context) { + context.toggleMute() + }, }, })