Skip to content

Commit

Permalink
Fix start time with web video player
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobozzz committed Oct 27, 2023
1 parent 2809ebb commit 049f50b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions client/src/assets/player/peertube-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ export class PeerTubePlayer {
const webVideoOptionsBuilder = new WebVideoOptionsBuilder(pick(this.currentLoadOptions, [
'videoFileToken',
'webVideo',
'hls',
'startTime'
'hls'
]))

this.player.webVideo(webVideoOptionsBuilder.getPluginOptions())
Expand Down
7 changes: 3 additions & 4 deletions client/src/assets/player/shared/peertube/peertube-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,10 @@ class PeerTubePlugin extends Plugin {

// Prefer canplaythrough instead of canplay because Chrome has issues with the second one
this.player.one('canplaythrough', () => {
if (this.options.startTime()) {
debugLogger('Start the video at ' + this.options.startTime())
const startTime = this.options.startTime() || 0
debugLogger('Start the video at ' + startTime)

this.player.currentTime(timeToInt(this.options.startTime()))
}
this.player.currentTime(timeToInt(startTime))

if (this.options.stopTime()) {
const stopTime = timeToInt(this.options.stopTime())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export class WebVideoOptionsBuilder {

videoFiles: this.options.webVideo.videoFiles.length !== 0
? this.options.webVideo.videoFiles
: this.options?.hls.videoFiles || [],

startTime: this.options.startTime
: this.options?.hls.videoFiles || []
}
}
}
1 change: 0 additions & 1 deletion client/src/assets/player/types/peertube-videojs-typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ type TheaterButtonOptions = {

type WebVideoPluginOptions = {
videoFiles: VideoFile[]
startTime: number | string
videoFileToken: () => string
}

Expand Down

0 comments on commit 049f50b

Please sign in to comment.