mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add video mute event.
This commit is contained in:
parent
0d5a447e13
commit
6fa8c3c1f8
@ -20,10 +20,12 @@ export function register(el: HTMLVideoElement, state: Video) {
|
||||
Vue.set(state, 'playing', false)
|
||||
})
|
||||
el.addEventListener('volumechange', (value) => {
|
||||
Vue.set(state, 'muted', el.muted)
|
||||
Vue.set(state, 'volume', el.volume)
|
||||
})
|
||||
|
||||
// Initial state
|
||||
Vue.set(state, 'muted', el.muted)
|
||||
Vue.set(state, 'volume', el.volume)
|
||||
Vue.set(state, 'playing', !el.paused)
|
||||
}
|
||||
|
@ -83,6 +83,7 @@
|
||||
playable: false,
|
||||
playing: false,
|
||||
volume: 0,
|
||||
muted: false,
|
||||
fullscreen: false,
|
||||
},
|
||||
control: {
|
||||
@ -156,6 +157,14 @@
|
||||
this._video.pause()
|
||||
}
|
||||
|
||||
public mute() {
|
||||
this._video.muted = true
|
||||
}
|
||||
|
||||
public unmute() {
|
||||
this._video.muted = false
|
||||
}
|
||||
|
||||
public setVolume(value: number) {
|
||||
if (value < 0 || value > 1) {
|
||||
throw new Error('Out of range. Value must be between 0 and 1.')
|
||||
|
@ -26,6 +26,7 @@ export interface Video {
|
||||
playable: boolean
|
||||
playing: boolean
|
||||
volume: number
|
||||
muted: boolean
|
||||
fullscreen: boolean
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user