diff options
author | Chocobozzz <me@florianbigard.com> | 2022-07-15 15:30:14 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-07-18 11:37:18 +0200 |
commit | 42b40636991b97fe818007fab19091764fc5db73 (patch) | |
tree | db431787c06ce898d22e91ff771f795219274fc6 /client/src/assets/player/shared/mobile/peertube-mobile-plugin.ts | |
parent | 654d4ede7fa4d0faa71e49bcfab6b65a686397b2 (diff) | |
download | PeerTube-42b40636991b97fe818007fab19091764fc5db73.tar.gz PeerTube-42b40636991b97fe818007fab19091764fc5db73.tar.zst PeerTube-42b40636991b97fe818007fab19091764fc5db73.zip |
Add ability for client to create server logs
Diffstat (limited to 'client/src/assets/player/shared/mobile/peertube-mobile-plugin.ts')
-rw-r--r-- | client/src/assets/player/shared/mobile/peertube-mobile-plugin.ts | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/client/src/assets/player/shared/mobile/peertube-mobile-plugin.ts b/client/src/assets/player/shared/mobile/peertube-mobile-plugin.ts index 91dda7f94..646e9f8c6 100644 --- a/client/src/assets/player/shared/mobile/peertube-mobile-plugin.ts +++ b/client/src/assets/player/shared/mobile/peertube-mobile-plugin.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | import { PeerTubeMobileButtons } from './peertube-mobile-buttons' | ||
2 | import videojs from 'video.js' | ||
3 | import debug from 'debug' | 1 | import debug from 'debug' |
2 | import videojs from 'video.js' | ||
3 | import { logger } from '@root-helpers/logger' | ||
4 | import { PeerTubeMobileButtons } from './peertube-mobile-buttons' | ||
4 | 5 | ||
5 | const logger = debug('peertube:player:mobile') | 6 | const debugLogger = debug('peertube:player:mobile') |
6 | 7 | ||
7 | const Plugin = videojs.getPlugin('plugin') | 8 | const Plugin = videojs.getPlugin('plugin') |
8 | 9 | ||
@@ -45,7 +46,7 @@ class PeerTubeMobilePlugin extends Plugin { | |||
45 | if (!this.player.isFullscreen() || this.isPortraitVideo()) return | 46 | if (!this.player.isFullscreen() || this.isPortraitVideo()) return |
46 | 47 | ||
47 | screen.orientation.lock('landscape') | 48 | screen.orientation.lock('landscape') |
48 | .catch(err => console.error('Cannot lock screen to landscape.', err)) | 49 | .catch(err => logger.error('Cannot lock screen to landscape.', err)) |
49 | }) | 50 | }) |
50 | } | 51 | } |
51 | 52 | ||
@@ -61,7 +62,7 @@ class PeerTubeMobilePlugin extends Plugin { | |||
61 | } | 62 | } |
62 | 63 | ||
63 | if (this.lastTapEvent && event.timeStamp - this.lastTapEvent.timeStamp < PeerTubeMobilePlugin.DOUBLE_TAP_DELAY_MS) { | 64 | if (this.lastTapEvent && event.timeStamp - this.lastTapEvent.timeStamp < PeerTubeMobilePlugin.DOUBLE_TAP_DELAY_MS) { |
64 | logger('Detected double tap') | 65 | debugLogger('Detected double tap') |
65 | 66 | ||
66 | this.lastTapEvent = undefined | 67 | this.lastTapEvent = undefined |
67 | this.onDoubleTap(event) | 68 | this.onDoubleTap(event) |
@@ -71,7 +72,7 @@ class PeerTubeMobilePlugin extends Plugin { | |||
71 | this.newActiveState = !this.player.userActive() | 72 | this.newActiveState = !this.player.userActive() |
72 | 73 | ||
73 | this.tapTimeout = setTimeout(() => { | 74 | this.tapTimeout = setTimeout(() => { |
74 | logger('No double tap detected, set user active state to %s.', this.newActiveState) | 75 | debugLogger('No double tap detected, set user active state to %s.', this.newActiveState) |
75 | 76 | ||
76 | this.player.userActive(this.newActiveState) | 77 | this.player.userActive(this.newActiveState) |
77 | }, PeerTubeMobilePlugin.DOUBLE_TAP_DELAY_MS) | 78 | }, PeerTubeMobilePlugin.DOUBLE_TAP_DELAY_MS) |
@@ -100,19 +101,19 @@ class PeerTubeMobilePlugin extends Plugin { | |||
100 | const rect = this.findPlayerTarget((event.target as HTMLElement)).getBoundingClientRect() | 101 | const rect = this.findPlayerTarget((event.target as HTMLElement)).getBoundingClientRect() |
101 | const offsetX = event.targetTouches[0].pageX - rect.left | 102 | const offsetX = event.targetTouches[0].pageX - rect.left |
102 | 103 | ||
103 | logger('Calculating double tap zone (player width: %d, offset X: %d)', playerWidth, offsetX) | 104 | debugLogger('Calculating double tap zone (player width: %d, offset X: %d)', playerWidth, offsetX) |
104 | 105 | ||
105 | if (offsetX > 0.66 * playerWidth) { | 106 | if (offsetX > 0.66 * playerWidth) { |
106 | if (this.seekAmount < 0) this.seekAmount = 0 | 107 | if (this.seekAmount < 0) this.seekAmount = 0 |
107 | 108 | ||
108 | this.seekAmount += 10 | 109 | this.seekAmount += 10 |
109 | 110 | ||
110 | logger('Will forward %d seconds', this.seekAmount) | 111 | debugLogger('Will forward %d seconds', this.seekAmount) |
111 | } else if (offsetX < 0.33 * playerWidth) { | 112 | } else if (offsetX < 0.33 * playerWidth) { |
112 | if (this.seekAmount > 0) this.seekAmount = 0 | 113 | if (this.seekAmount > 0) this.seekAmount = 0 |
113 | 114 | ||
114 | this.seekAmount -= 10 | 115 | this.seekAmount -= 10 |
115 | logger('Will rewind %d seconds', this.seekAmount) | 116 | debugLogger('Will rewind %d seconds', this.seekAmount) |
116 | } | 117 | } |
117 | 118 | ||
118 | this.peerTubeMobileButtons.displayFastSeek(this.seekAmount) | 119 | this.peerTubeMobileButtons.displayFastSeek(this.seekAmount) |