diff --git a/client/src/components/video.vue b/client/src/components/video.vue index f50aa907..ef3cc3c0 100644 --- a/client/src/components/video.vue +++ b/client/src/components/video.vue @@ -312,8 +312,9 @@ this._video.addEventListener('canplaythrough', () => { this.$accessor.video.setPlayable(true) if (this.autoplay) { - if (!document.hasFocus()) { + if (!document.hasFocus() || !this.$accessor.active) { this.$accessor.video.setMuted(true) + this._video.muted = true } this.$nextTick(() => { @@ -345,12 +346,16 @@ return } - this._video - .play() - .then(() => { - this.onResise() - }) - .catch(err => this.$log.error(err)) + try { + this._video + .play() + .then(() => { + this.onResise() + }) + .catch(err => this.$log.error) + } catch (err) { + this.$log.error(err) + } } pause() { @@ -379,7 +384,7 @@ } onFocus() { - if (!document.hasFocus()) { + if (!document.hasFocus() || !this.$accessor.active) { return } @@ -388,6 +393,7 @@ .readText() .then(text => { if (this.clipboard !== text) { + this.$accessor.remote.setClipboard(text) this.$accessor.remote.sendClipboard(text) } }) diff --git a/client/src/main.ts b/client/src/main.ts index e8b85d47..fe21c50d 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -27,6 +27,15 @@ new Vue({ store, render: h => h(app), created() { + const click = () => { + this.$accessor.setActive() + if (this.$accessor.settings.autoplay && this.$accessor.video.playing) { + this.$accessor.video.setMuted(false) + } + window.removeEventListener('click', click, false) + } + window.addEventListener('click', click, false) + this.$client.init(this) this.$accessor.initialise() }, diff --git a/client/src/store/index.ts b/client/src/store/index.ts index 386bca37..b7d1bce8 100644 --- a/client/src/store/index.ts +++ b/client/src/store/index.ts @@ -15,12 +15,17 @@ import * as emoji from './emoji' export const state = () => ({ username: get('username', ''), password: get('password', ''), + active: false, connecting: false, connected: false, locked: false, }) export const mutations = mutationTree(state, { + setActive(state) { + state.active = true + }, + setLogin(state, { username, password }: { username: string; password: string }) { state.username = username state.password = password