aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player')
-rw-r--r--client/src/assets/player/peertube-player.ts6
-rw-r--r--client/src/assets/player/peertube-videojs-plugin.ts24
-rw-r--r--client/src/assets/player/peertube-videojs-typings.ts1
3 files changed, 22 insertions, 9 deletions
diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts
index 58a8aa26c..e8a258065 100644
--- a/client/src/assets/player/peertube-player.ts
+++ b/client/src/assets/player/peertube-player.ts
@@ -21,7 +21,8 @@ function getVideojsOptions (options: {
21 enableHotkeys: boolean, 21 enableHotkeys: boolean,
22 inactivityTimeout: number, 22 inactivityTimeout: number,
23 peertubeLink: boolean, 23 peertubeLink: boolean,
24 poster: string 24 poster: string,
25 startTime: number
25}) { 26}) {
26 const videojsOptions = { 27 const videojsOptions = {
27 controls: true, 28 controls: true,
@@ -34,7 +35,8 @@ function getVideojsOptions (options: {
34 videoFiles: options.videoFiles, 35 videoFiles: options.videoFiles,
35 playerElement: options.playerElement, 36 playerElement: options.playerElement,
36 videoViewUrl: options.videoViewUrl, 37 videoViewUrl: options.videoViewUrl,
37 videoDuration: options.videoDuration 38 videoDuration: options.videoDuration,
39 startTime: options.startTime
38 } 40 }
39 }, 41 },
40 controlBar: { 42 controlBar: {
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts
index 2eddcb1d8..ddb73d074 100644
--- a/client/src/assets/player/peertube-videojs-plugin.ts
+++ b/client/src/assets/player/peertube-videojs-plugin.ts
@@ -36,6 +36,7 @@ class PeerTubePlugin extends Plugin {
36 private readonly playerElement: HTMLVideoElement 36 private readonly playerElement: HTMLVideoElement
37 37
38 private readonly autoplay: boolean = false 38 private readonly autoplay: boolean = false
39 private readonly startTime: number = 0
39 private readonly savePlayerSrcFunction: Function 40 private readonly savePlayerSrcFunction: Function
40 private readonly videoFiles: VideoFile[] 41 private readonly videoFiles: VideoFile[]
41 private readonly videoViewUrl: string 42 private readonly videoViewUrl: string
@@ -71,6 +72,7 @@ class PeerTubePlugin extends Plugin {
71 this.autoplay = this.player.options_.autoplay 72 this.autoplay = this.player.options_.autoplay
72 this.player.options_.autoplay = false 73 this.player.options_.autoplay = false
73 74
75 this.startTime = options.startTime
74 this.videoFiles = options.videoFiles 76 this.videoFiles = options.videoFiles
75 this.videoViewUrl = options.videoViewUrl 77 this.videoViewUrl = options.videoViewUrl
76 this.videoDuration = options.videoDuration 78 this.videoDuration = options.videoDuration
@@ -94,7 +96,7 @@ class PeerTubePlugin extends Plugin {
94 this.runViewAdd() 96 this.runViewAdd()
95 97
96 this.player.one('play', () => { 98 this.player.one('play', () => {
97 // Don't run immediately scheduler, wait some seconds the TCP connections are maid 99 // Don't run immediately scheduler, wait some seconds the TCP connections are made
98 this.runAutoQualitySchedulerTimer = setTimeout(() => { 100 this.runAutoQualitySchedulerTimer = setTimeout(() => {
99 this.runAutoQualityScheduler() 101 this.runAutoQualityScheduler()
100 }, this.CONSTANTS.AUTO_QUALITY_SCHEDULER) 102 }, this.CONSTANTS.AUTO_QUALITY_SCHEDULER)
@@ -234,10 +236,7 @@ class PeerTubePlugin extends Plugin {
234 } 236 }
235 237
236 const newVideoFile = this.videoFiles.find(f => f.resolution.id === resolutionId) 238 const newVideoFile = this.videoFiles.find(f => f.resolution.id === resolutionId)
237 this.updateVideoFile(newVideoFile, delay, () => { 239 this.updateVideoFile(newVideoFile, delay, () => this.seek(currentTime))
238 this.player.currentTime(currentTime)
239 this.player.handleTechSeeked_()
240 })
241 } 240 }
242 241
243 flushVideoFile (videoFile: VideoFile, destroyRenderer = true) { 242 flushVideoFile (videoFile: VideoFile, destroyRenderer = true) {
@@ -263,6 +262,11 @@ class PeerTubePlugin extends Plugin {
263 this.trigger('autoResolutionUpdate') 262 this.trigger('autoResolutionUpdate')
264 } 263 }
265 264
265 private seek (time: number) {
266 this.player.currentTime(time)
267 this.player.handleTechSeeked_()
268 }
269
266 private getAppropriateFile (averageDownloadSpeed?: number): VideoFile { 270 private getAppropriateFile (averageDownloadSpeed?: number): VideoFile {
267 if (this.videoFiles === undefined || this.videoFiles.length === 0) return undefined 271 if (this.videoFiles === undefined || this.videoFiles.length === 0) return undefined
268 if (this.videoFiles.length === 1) return this.videoFiles[0] 272 if (this.videoFiles.length === 1) return this.videoFiles[0]
@@ -310,12 +314,18 @@ class PeerTubePlugin extends Plugin {
310 314
311 if (this.autoplay === true) { 315 if (this.autoplay === true) {
312 this.player.posterImage.hide() 316 this.player.posterImage.hide()
313 this.updateVideoFile(undefined, 0, () => this.player.play()) 317 this.updateVideoFile(undefined, 0, () => {
318 this.seek(this.startTime)
319 this.player.play()
320 })
314 } else { 321 } else {
315 // Proxy first play 322 // Proxy first play
316 const oldPlay = this.player.play.bind(this.player) 323 const oldPlay = this.player.play.bind(this.player)
317 this.player.play = () => { 324 this.player.play = () => {
318 this.updateVideoFile(undefined, 0, () => oldPlay) 325 this.updateVideoFile(undefined, 0, () => {
326 this.seek(this.startTime)
327 oldPlay()
328 })
319 this.player.play = oldPlay 329 this.player.play = oldPlay
320 } 330 }
321 } 331 }
diff --git a/client/src/assets/player/peertube-videojs-typings.ts b/client/src/assets/player/peertube-videojs-typings.ts
index a58fa6505..a66caa30b 100644
--- a/client/src/assets/player/peertube-videojs-typings.ts
+++ b/client/src/assets/player/peertube-videojs-typings.ts
@@ -21,6 +21,7 @@ type PeertubePluginOptions = {
21 playerElement: HTMLVideoElement 21 playerElement: HTMLVideoElement
22 videoViewUrl: string 22 videoViewUrl: string
23 videoDuration: number 23 videoDuration: number
24 startTime: number
24} 25}
25 26
26// videojs typings don't have some method we need 27// videojs typings don't have some method we need