From 64c1075b06e2de944aa2151ca0d0936cad1c02bb Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sun, 3 Feb 2019 19:33:23 +0900 Subject: [PATCH] Remember the media playback volume (#4089) * Remember the media playback volume * fix --- .../app/common/views/components/media-banner.vue | 13 ++++++++++++- .../desktop/views/components/media-video-dialog.vue | 11 ++++++++--- src/client/app/store.ts | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/client/app/common/views/components/media-banner.vue b/src/client/app/common/views/components/media-banner.vue index 17e4dd6041..8a6f377f01 100644 --- a/src/client/app/common/views/components/media-banner.vue +++ b/src/client/app/common/views/components/media-banner.vue @@ -11,6 +11,7 @@ :title="media.name" controls ref="audio" + @volumechange="volumechange" preload="metadata" /> diff --git a/src/client/app/desktop/views/components/media-video-dialog.vue b/src/client/app/desktop/views/components/media-video-dialog.vue index cb112e5266..3c682ecefb 100644 --- a/src/client/app/desktop/views/components/media-video-dialog.vue +++ b/src/client/app/desktop/views/components/media-video-dialog.vue @@ -1,7 +1,7 @@ @@ -18,8 +18,9 @@ export default Vue.extend({ duration: 100, easing: 'linear' }); - const videoTag = this.$refs.video as HTMLVideoElement + const videoTag = this.$refs.video as HTMLVideoElement; if (this.start) videoTag.currentTime = this.start + videoTag.volume = this.$store.state.device.mediaVolume; }, methods: { close() { @@ -30,7 +31,11 @@ export default Vue.extend({ easing: 'linear', complete: () => this.destroyDom() }); - } + }, + volumechange() { + const videoTag = this.$refs.video as HTMLVideoElement; + this.$store.commit('device/set', { key: 'mediaVolume', value: videoTag.volume }); + }, } }); diff --git a/src/client/app/store.ts b/src/client/app/store.ts index 46655b7bd5..8cde2d3595 100644 --- a/src/client/app/store.ts +++ b/src/client/app/store.ts @@ -56,6 +56,7 @@ const defaultDeviceSettings = { themes: [], enableSounds: true, soundVolume: 0.5, + mediaVolume: 0.5, lang: null, preventUpdate: false, debug: false,