Archived
2
0

mute video if not focused

This commit is contained in:
Craig 2020-02-12 04:16:49 +00:00
parent 33384c0408
commit fc43a0a3ab
2 changed files with 9 additions and 0 deletions

View File

@ -312,6 +312,10 @@
this._video.addEventListener('canplaythrough', () => {
this.$accessor.video.setPlayable(true)
if (this.autoplay) {
if (!document.hasFocus()) {
this.$accessor.video.setMuted(true)
}
this.$nextTick(() => {
this.$accessor.video.play()
})

View File

@ -47,6 +47,11 @@ export const mutations = mutationTree(state, {
}
},
setMuted(state, muted: boolean) {
state.muted = muted
set('mute', muted)
},
toggleMute(state) {
state.muted = !state.muted
set('mute', state.muted)