forked from FoundKeyGang/FoundKey
Remember the media playback volume (#4089)
* Remember the media playback volume * fix
This commit is contained in:
parent
217e4ee39c
commit
64c1075b06
3 changed files with 21 additions and 4 deletions
|
@ -11,6 +11,7 @@
|
|||
:title="media.name"
|
||||
controls
|
||||
ref="audio"
|
||||
@volumechange="volumechange"
|
||||
preload="metadata" />
|
||||
</div>
|
||||
<a class="download" v-else
|
||||
|
@ -40,7 +41,17 @@ export default Vue.extend({
|
|||
return {
|
||||
hide: true
|
||||
};
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
const audioTag = this.$refs.audio as HTMLAudioElement;
|
||||
audioTag.volume = this.$store.state.device.mediaVolume;
|
||||
},
|
||||
methods: {
|
||||
volumechange() {
|
||||
const audioTag = this.$refs.audio as HTMLAudioElement;
|
||||
this.$store.commit('device/set', { key: 'mediaVolume', value: audioTag.volume });
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div class="mk-media-video-dialog">
|
||||
<div class="bg" @click="close"></div>
|
||||
<video :src="video.url" :title="video.name" controls autoplay ref="video"/>
|
||||
<video :src="video.url" :title="video.name" controls autoplay ref="video" @volumechange="volumechange"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -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 });
|
||||
},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -56,6 +56,7 @@ const defaultDeviceSettings = {
|
|||
themes: [],
|
||||
enableSounds: true,
|
||||
soundVolume: 0.5,
|
||||
mediaVolume: 0.5,
|
||||
lang: null,
|
||||
preventUpdate: false,
|
||||
debug: false,
|
||||
|
|
Loading…
Reference in a new issue