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.playerElement = options.playerElement
+ if (this.autoplay === true) this.player.addClass('vjs-has-autoplay')
+
this.player.ready(() => {
const volume = getStoredVolume()
if (volume !== undefined) this.player.volume(volume)
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))
} else {
// Proxy first play
const oldPlay = this.player.play.bind(this.player)
this.player.play = () => {
- this.updateVideoFile(undefined, 0, () => oldPlay)
+ this.player.addClass('vjs-has-big-play-button-clicked')
this.player.play = oldPlay
+
+ this.updateVideoFile(undefined, 0, () => this.seek(this.startTime))
}
}
}