From ed8a74625cc6f0940eafaa9e9c067f93477146cf Mon Sep 17 00:00:00 2001 From: Preston Date: Fri, 21 Feb 2020 13:31:32 -0500 Subject: [PATCH] Hide Mouse when on top of video player --- .../ft-video-player/ft-video-player.js | 33 +++++++++++++++++++ .../watch-video-info/watch-video-info.css | 2 +- src/renderer/views/Watch/Watch.js | 12 +++++++ src/renderer/views/Watch/Watch.vue | 1 + 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index 43ff16b0..c8e84989 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -50,6 +50,7 @@ export default Vue.extend({ useDash: false, useHls: false, activeSourceList: [], + mouseTimeout: null, dataSetup: { aspectRatio: '16:9', nativeTextTracks: false, @@ -115,6 +116,7 @@ export default Vue.extend({ if (this.player !== null && !this.player.isInPictureInPicture()) { this.player.dispose() this.player = null + clearTimeout(this.mouseTimeout) } }, methods: { @@ -147,6 +149,15 @@ export default Vue.extend({ } $(document).on('keydown', this.keyboardShortcutHandler) + + this.player.on('mousemove', this.hideMouseTimeout) + this.player.on('mouseleave', this.removeMouseTimeout) + + const v = this + + this.player.on('error', function (error, message) { + v.$emit('error', error.target.player.error_) + }) } }, @@ -261,6 +272,27 @@ export default Vue.extend({ } }, + hideMouseTimeout: function () { + if (this.id === '') { + return + } + + const videoPlayer = $(`#${this.id} video`).get(0) + if (typeof (videoPlayer) !== 'undefined') { + videoPlayer.style.cursor = 'default' + clearTimeout(this.mouseTimeout) + this.mouseTimeout = window.setTimeout(function () { + videoPlayer.style.cursor = 'none' + }, 2650) + } + }, + + removeMouseTimeout: function () { + if (this.mouseTimeout !== null) { + clearTimeout(this.mouseTimeout) + } + }, + keyboardShortcutHandler: function (event) { const activeInputs = $('.ft-input') @@ -396,6 +428,7 @@ export default Vue.extend({ if (this.player !== null && !this.player.isInPictureInPicture()) { this.player.dispose() this.player = null + clearTimeout(this.mouseTimeout) } } }) diff --git a/src/renderer/components/watch-video-info/watch-video-info.css b/src/renderer/components/watch-video-info/watch-video-info.css index 54da2bc7..efcb6631 100644 --- a/src/renderer/components/watch-video-info/watch-video-info.css +++ b/src/renderer/components/watch-video-info/watch-video-info.css @@ -4,7 +4,7 @@ .videoTitle { font-size: 22px; - max-width: 60%; + max-width: 50%; } .channelInformation { diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index dd81dc22..019ad522 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -258,6 +258,18 @@ export default Vue.extend({ setTimeout(() => { this.hidePlayer = false }, 100) + }, + + handleVideoError: function (error) { + console.log(error) + if (error.code === 4) { + if (this.activeFormat === 'dash') { + console.log('Unable to play dash formats. Reverting to legacy formats...') + this.enableLegacyFormat() + } else { + this.enableDashFormat() + } + } } } }) diff --git a/src/renderer/views/Watch/Watch.vue b/src/renderer/views/Watch/Watch.vue index 2f9ac8aa..df16f9a9 100644 --- a/src/renderer/views/Watch/Watch.vue +++ b/src/renderer/views/Watch/Watch.vue @@ -14,6 +14,7 @@ class="videoPlayer" :class="{ theatrePlayer: useTheatreMode }" ref="videoPlayer" + @error="handleVideoError" />