diff --git a/src/component/internal/video.ts b/src/component/internal/video.ts index 0446a2bc..9b284bb5 100644 --- a/src/component/internal/video.ts +++ b/src/component/internal/video.ts @@ -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) } diff --git a/src/component/main.vue b/src/component/main.vue index 347c49b9..8e979eaa 100644 --- a/src/component/main.vue +++ b/src/component/main.vue @@ -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.') diff --git a/src/component/types/state.ts b/src/component/types/state.ts index eeebd644..3e59974e 100644 --- a/src/component/types/state.ts +++ b/src/component/types/state.ts @@ -25,7 +25,8 @@ export interface Connection { export interface Video { playable: boolean playing: boolean - volume: number + volume: number + muted: boolean fullscreen: boolean }