Add touch controls to video player (Hold to pause, doubel tap to fullscreen)

This commit is contained in:
Preston 2021-01-15 22:34:49 -05:00
parent aeeb911f0f
commit aa6b2925ed
2 changed files with 23 additions and 0 deletions

View File

@ -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')

View File

@ -6,6 +6,8 @@
:poster="thumbnail"
controls
preload="auto"
@touchstart="handleTouchStart"
@touchend="handleTouchEnd"
:data-setup="JSON.stringify(dataSetup)"
>
<source