if (this.video && this.video.uuid === uuid) return
this.videoService.getVideo(uuid).subscribe(
- video => this.onVideoFetched(video),
+ video => {
+ const startTime = this.route.snapshot.queryParams.start
+ this.onVideoFetched(video, startTime)
+ .catch(err => this.handleError(err))
+ },
error => {
this.videoNotFound = true
)
}
- private async onVideoFetched (video: VideoDetails) {
+ private async onVideoFetched (video: VideoDetails, startTime = 0) {
this.video = video
// Re init attributes
videoDuration: this.video.duration,
enableHotkeys: true,
peertubeLink: false,
- poster: this.video.previewUrl
+ poster: this.video.previewUrl,
+ startTime
})
const self = this
private readonly playerElement: HTMLVideoElement
private readonly autoplay: boolean = false
+ private readonly startTime: number = 0
private readonly savePlayerSrcFunction: Function
private readonly videoFiles: VideoFile[]
private readonly videoViewUrl: string
this.autoplay = this.player.options_.autoplay
this.player.options_.autoplay = false
+ this.startTime = options.startTime
this.videoFiles = options.videoFiles
this.videoViewUrl = options.videoViewUrl
this.videoDuration = options.videoDuration
this.runViewAdd()
this.player.one('play', () => {
- // Don't run immediately scheduler, wait some seconds the TCP connections are maid
+ // Don't run immediately scheduler, wait some seconds the TCP connections are made
this.runAutoQualitySchedulerTimer = setTimeout(() => {
this.runAutoQualityScheduler()
}, this.CONSTANTS.AUTO_QUALITY_SCHEDULER)
}
const newVideoFile = this.videoFiles.find(f => f.resolution.id === resolutionId)
- this.updateVideoFile(newVideoFile, delay, () => {
- this.player.currentTime(currentTime)
- this.player.handleTechSeeked_()
- })
+ this.updateVideoFile(newVideoFile, delay, () => this.seek(currentTime))
}
flushVideoFile (videoFile: VideoFile, destroyRenderer = true) {
this.trigger('autoResolutionUpdate')
}
+ private seek (time: number) {
+ this.player.currentTime(time)
+ this.player.handleTechSeeked_()
+ }
+
private getAppropriateFile (averageDownloadSpeed?: number): VideoFile {
if (this.videoFiles === undefined || this.videoFiles.length === 0) return undefined
if (this.videoFiles.length === 1) return this.videoFiles[0]
if (this.autoplay === true) {
this.player.posterImage.hide()
- this.updateVideoFile(undefined, 0, () => this.player.play())
+ this.updateVideoFile(undefined, 0, () => {
+ this.seek(this.startTime)
+ this.player.play()
+ })
} else {
// Proxy first play
const oldPlay = this.player.play.bind(this.player)
this.player.play = () => {
- this.updateVideoFile(undefined, 0, () => oldPlay)
+ this.updateVideoFile(undefined, 0, () => {
+ this.seek(this.startTime)
+ oldPlay()
+ })
this.player.play = oldPlay
}
}
const videoElement = document.getElementById(videoContainerId) as HTMLVideoElement
let autoplay = false
+ let startTime = 0
try {
let params = new URL(window.location.toString()).searchParams
autoplay = params.has('autoplay') && (params.get('autoplay') === '1' || params.get('autoplay') === 'true')
+
+ const startTimeParamString = params.get('start')
+ const startTimeParamNumber = parseInt(startTimeParamString, 10)
+ if (isNaN(startTimeParamNumber) === false) startTime = startTimeParamNumber
} catch (err) {
console.error('Cannot get params from URL.', err)
}
videoDuration: videoInfo.duration,
enableHotkeys: true,
peertubeLink: true,
- poster: window.location.origin + videoInfo.previewPath
+ poster: window.location.origin + videoInfo.previewPath,
+ startTime
})
videojs(videoContainerId, videojsOptions, function () {
const player = this