diff --git a/src/app.vue b/src/app.vue
index 500edadc..784c510c 100644
--- a/src/app.vue
+++ b/src/app.vue
@@ -33,11 +33,11 @@
video.playing |
- {{ neko.state.video.playing }} |
+ |
-
+
video.volume |
- {{ neko.state.video.volume }} |
+ |
control.scroll.inverse |
@@ -133,8 +133,8 @@
-
-
+
+
diff --git a/src/components/canvas.vue b/src/components/canvas.vue
index 7a47595a..3ad1c843 100644
--- a/src/components/canvas.vue
+++ b/src/components/canvas.vue
@@ -71,7 +71,7 @@
export default class extends Vue {
@Ref('component') readonly _component!: HTMLElement
@Ref('container') readonly _container!: HTMLElement
- @Ref('video') public readonly video!: HTMLVideoElement
+ @Ref('video') readonly video!: HTMLVideoElement
private websocket = new NekoWebSocket()
private webrtc = new NekoWebRTC()
@@ -126,6 +126,26 @@
return this.state.connection.websocket == 'connected' && this.state.connection.webrtc == 'connected'
}
+ @Watch('state.video.playing')
+ onVideoPlayingChanged(play: boolean) {
+ if (this.video.paused && play) {
+ this.video.play()
+ }
+
+ if (!this.video.paused && !play) {
+ this.video.pause()
+ }
+ }
+
+ @Watch('state.video.volume')
+ onVideoVolumeChanged(value: number) {
+ if (value < 0 || value > 1) {
+ throw new Error('Out of range. Value must be between 0 and 1.')
+ }
+
+ this.video.volume = value
+ }
+
@Watch('state.screen.size')
onScreenSizeChanged() {
this.onResize()
diff --git a/src/internal/video.ts b/src/internal/video.ts
index fdd99800..9b6de7d5 100644
--- a/src/internal/video.ts
+++ b/src/internal/video.ts
@@ -20,6 +20,10 @@ export function register(el: HTMLVideoElement, state: Video) {
Vue.set(state, 'playing', false)
})
el.addEventListener('volumechange', (value) => {
- Vue.set(state, 'volume', value)
+ Vue.set(state, 'volume', el.volume)
})
+
+ // Initial state
+ Vue.set(state, 'volume', el.volume)
+ Vue.set(state, 'playing', !el.paused)
}