diff options
author | Chocobozzz <me@florianbigard.com> | 2023-02-25 16:18:28 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-02-25 16:18:28 +0100 |
commit | 6de076222aca7005371e01768171efdc62ed8018 (patch) | |
tree | 3e8a34d5634cb91a9a1cd20e5043961b0fddc7fe /client/src/assets | |
parent | c0687c91b9cf185c36e477ab30266c779f792ee1 (diff) | |
download | PeerTube-6de076222aca7005371e01768171efdc62ed8018.tar.gz PeerTube-6de076222aca7005371e01768171efdc62ed8018.tar.zst PeerTube-6de076222aca7005371e01768171efdc62ed8018.zip |
Avoid always resuming the end of the video
Diffstat (limited to 'client/src/assets')
4 files changed, 10 insertions, 6 deletions
diff --git a/client/src/assets/player/shared/manager-options/manager-options-builder.ts b/client/src/assets/player/shared/manager-options/manager-options-builder.ts index c820d637b..5d3ee4c4a 100644 --- a/client/src/assets/player/shared/manager-options/manager-options-builder.ts +++ b/client/src/assets/player/shared/manager-options/manager-options-builder.ts | |||
@@ -35,6 +35,7 @@ export class ManagerOptionsBuilder { | |||
35 | 35 | ||
36 | ...pick(commonOptions, [ | 36 | ...pick(commonOptions, [ |
37 | 'videoViewUrl', | 37 | 'videoViewUrl', |
38 | 'videoViewIntervalMs', | ||
38 | 'authorizationHeader', | 39 | 'authorizationHeader', |
39 | 'startTime', | 40 | 'startTime', |
40 | 'videoDuration', | 41 | 'videoDuration', |
diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts index ec8fbb320..b5f177f30 100644 --- a/client/src/assets/player/shared/peertube/peertube-plugin.ts +++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts | |||
@@ -27,9 +27,7 @@ class PeerTubePlugin extends Plugin { | |||
27 | private readonly videoUUID: string | 27 | private readonly videoUUID: string |
28 | private readonly startTime: number | 28 | private readonly startTime: number |
29 | 29 | ||
30 | private readonly CONSTANTS = { | 30 | private readonly videoViewIntervalMs: number |
31 | USER_VIEW_VIDEO_INTERVAL: 5000 // Every 5 seconds, notify the user is watching the video | ||
32 | } | ||
33 | 31 | ||
34 | private videoCaptions: VideoJSCaption[] | 32 | private videoCaptions: VideoJSCaption[] |
35 | private defaultSubtitle: string | 33 | private defaultSubtitle: string |
@@ -48,6 +46,7 @@ class PeerTubePlugin extends Plugin { | |||
48 | this.authorizationHeader = options.authorizationHeader | 46 | this.authorizationHeader = options.authorizationHeader |
49 | this.videoUUID = options.videoUUID | 47 | this.videoUUID = options.videoUUID |
50 | this.startTime = timeToInt(options.startTime) | 48 | this.startTime = timeToInt(options.startTime) |
49 | this.videoViewIntervalMs = options.videoViewIntervalMs | ||
51 | 50 | ||
52 | this.videoCaptions = options.videoCaptions | 51 | this.videoCaptions = options.videoCaptions |
53 | this.initialInactivityTimeout = this.player.options_.inactivityTimeout | 52 | this.initialInactivityTimeout = this.player.options_.inactivityTimeout |
@@ -188,7 +187,7 @@ class PeerTubePlugin extends Plugin { | |||
188 | }) | 187 | }) |
189 | 188 | ||
190 | this.player.one('ended', () => { | 189 | this.player.one('ended', () => { |
191 | const currentTime = Math.round(this.player.duration()) | 190 | const currentTime = Math.floor(this.player.duration()) |
192 | lastCurrentTime = currentTime | 191 | lastCurrentTime = currentTime |
193 | 192 | ||
194 | this.notifyUserIsWatching(currentTime, lastViewEvent) | 193 | this.notifyUserIsWatching(currentTime, lastViewEvent) |
@@ -197,7 +196,7 @@ class PeerTubePlugin extends Plugin { | |||
197 | }) | 196 | }) |
198 | 197 | ||
199 | this.videoViewInterval = setInterval(() => { | 198 | this.videoViewInterval = setInterval(() => { |
200 | const currentTime = Math.round(this.player.currentTime()) | 199 | const currentTime = Math.floor(this.player.currentTime()) |
201 | 200 | ||
202 | // No need to update | 201 | // No need to update |
203 | if (currentTime === lastCurrentTime) return | 202 | if (currentTime === lastCurrentTime) return |
@@ -213,7 +212,7 @@ class PeerTubePlugin extends Plugin { | |||
213 | if (!this.authorizationHeader()) { | 212 | if (!this.authorizationHeader()) { |
214 | saveVideoWatchHistory(this.videoUUID, currentTime) | 213 | saveVideoWatchHistory(this.videoUUID, currentTime) |
215 | } | 214 | } |
216 | }, this.CONSTANTS.USER_VIEW_VIDEO_INTERVAL) | 215 | }, this.videoViewIntervalMs) |
217 | } | 216 | } |
218 | 217 | ||
219 | private notifyUserIsWatching (currentTime: number, viewEvent: VideoViewEvent) { | 218 | private notifyUserIsWatching (currentTime: number, viewEvent: VideoViewEvent) { |
diff --git a/client/src/assets/player/types/manager-options.ts b/client/src/assets/player/types/manager-options.ts index 3fbcec29c..c14fd7e99 100644 --- a/client/src/assets/player/types/manager-options.ts +++ b/client/src/assets/player/types/manager-options.ts | |||
@@ -55,6 +55,8 @@ export interface CommonOptions extends CustomizationOptions { | |||
55 | inactivityTimeout: number | 55 | inactivityTimeout: number |
56 | poster: string | 56 | poster: string |
57 | 57 | ||
58 | videoViewIntervalMs: number | ||
59 | |||
58 | instanceName: string | 60 | instanceName: string |
59 | 61 | ||
60 | theaterButton: boolean | 62 | theaterButton: boolean |
diff --git a/client/src/assets/player/types/peertube-videojs-typings.ts b/client/src/assets/player/types/peertube-videojs-typings.ts index 5674f78cb..eadf56cfa 100644 --- a/client/src/assets/player/types/peertube-videojs-typings.ts +++ b/client/src/assets/player/types/peertube-videojs-typings.ts | |||
@@ -108,6 +108,8 @@ type PeerTubePluginOptions = { | |||
108 | isLive: boolean | 108 | isLive: boolean |
109 | 109 | ||
110 | videoUUID: string | 110 | videoUUID: string |
111 | |||
112 | videoViewIntervalMs: number | ||
111 | } | 113 | } |
112 | 114 | ||
113 | type MetricsPluginOptions = { | 115 | type MetricsPluginOptions = { |