diff --git a/package.json b/package.json index 8192347d..3a9a7821 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "video.js": "7.18.1", "videojs-contrib-quality-levels": "^2.1.0", "videojs-http-source-selector": "^1.1.6", + "videojs-mobile-ui": "^0.8.0", "videojs-overlay": "^2.1.4", "videojs-vtt-thumbnails-freetube": "0.0.15", "vue": "^2.7.13", 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 7b7a80e2..ad10b3b9 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -11,7 +11,8 @@ import 'videojs-overlay/dist/videojs-overlay.css' import 'videojs-vtt-thumbnails-freetube' import 'videojs-contrib-quality-levels' import 'videojs-http-source-selector' - +import 'videojs-mobile-ui' +import 'videojs-mobile-ui/dist/videojs-mobile-ui.css' import { IpcChannels } from '../../../constants' import { sponsorBlockSkipSegments } from '../../helpers/sponsorblock' import { calculateColorLuminance, colors, showToast } from '../../helpers/utils' @@ -105,11 +106,11 @@ export default Vue.extend({ activeAdaptiveFormats: [], mouseTimeout: null, touchTimeout: null, - lastTouchTime: null, playerStats: null, statsModal: null, showStatsModal: false, statsModalEventName: 'updateStats', + usingTouch: false, dataSetup: { fluid: true, nativeTextTracks: false, @@ -364,6 +365,22 @@ export default Vue.extend({ } } }) + this.player.mobileUi({ + fullscreen: { + enterOnRotate: true, + exitOnRotate: true, + lockOnRotate: false + }, + // Without this flag, the mobile UI will only activate + // if videojs detects it is in Android or iOS + // With this flag, the mobile UI could theoretically + // work on any device that has a touch input + forceForTesting: true, + touchControls: { + seekSeconds: this.defaultSkipInterval, + tapTimeout: 300 + } + }) this.player.volume(this.volume) this.player.playbackRate(this.defaultPlayback) @@ -1678,23 +1695,16 @@ export default Vue.extend({ } }, - handleTouchStart: function (event) { - this.touchPauseTimeout = setTimeout(() => { - this.togglePlayPause() - }, 1000) - - const touchTime = new Date() - - if (this.lastTouchTime !== null && (touchTime.getTime() - this.lastTouchTime.getTime()) < 250) { - this.toggleFullscreen() - } - - this.lastTouchTime = touchTime + handleTouchStart: function () { + this.usingTouch = true }, - handleTouchEnd: function (event) { - clearTimeout(this.touchPauseTimeout) + handleMouseOver: function () { + // This addresses a discrepancy that only seems to occur in the mobile version of firefox + if (navigator.userAgent.search('Firefox') !== -1 && (videojs.browser.IS_ANDROID || videojs.browser.IS_IOS)) { return } + this.usingTouch = false }, + toggleShowStatsModal: function() { if (this.format !== 'dash') { showToast(this.$t('Video.Stats.Video statistics are not available for legacy videos')) 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 cf5680e4..2685e9b8 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.vue +++ b/src/renderer/components/ft-video-player/ft-video-player.vue @@ -1,5 +1,12 @@