From aa6b2925ed045bdd1932c7cb1d5f7e3255f24315 Mon Sep 17 00:00:00 2001 From: Preston Date: Fri, 15 Jan 2021 22:34:49 -0500 Subject: [PATCH] Add touch controls to video player (Hold to pause, doubel tap to fullscreen) --- .../ft-video-player/ft-video-player.js | 21 +++++++++++++++++++ .../ft-video-player/ft-video-player.vue | 2 ++ 2 files changed, 23 insertions(+) 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 98b76249..11e4ce87 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -76,6 +76,8 @@ export default Vue.extend({ maxFramerate: 0, activeSourceList: [], mouseTimeout: null, + touchTimeout: null, + lastTouchTime: null, dataSetup: { fluid: true, nativeTextTracks: false, @@ -719,6 +721,25 @@ export default Vue.extend({ } }, + handleTouchStart: function (event) { + const v = this + this.touchPauseTimeout = setTimeout(() => { + v.togglePlayPause() + }, 1000) + + const touchTime = new Date() + + if (this.lastTouchTime !== null && (touchTime.getTime() - this.lastTouchTime.getTime()) < 250) { + this.toggleFullscreen() + } + + this.lastTouchTime = touchTime + }, + + handleTouchEnd: function (event) { + clearTimeout(this.touchPauseTimeout) + }, + keyboardShortcutHandler: function (event) { const activeInputs = $('.ft-input') diff --git a/src/renderer/components/ft-video-player/ft-video-player.vue b/src/renderer/components/ft-video-player/ft-video-player.vue index 0827a643..80965573 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.vue +++ b/src/renderer/components/ft-video-player/ft-video-player.vue @@ -6,6 +6,8 @@ :poster="thumbnail" controls preload="auto" + @touchstart="handleTouchStart" + @touchend="handleTouchEnd" :data-setup="JSON.stringify(dataSetup)" >