import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo, VideoJSComponentInterface } from '../peertube-videojs-typings'
import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from 'p2p-media-loader-hlsjs'
import { Events } from 'p2p-media-loader-core'
+import { timeToInt } from '../utils'
// videojs-hlsjs-plugin needs videojs in window
window['videojs'] = videojs
totalDownload: 0,
totalUpload: 0
}
+ private startTime: number
private networkInfoInterval: any
initVideoJsContribHlsJsPlayer(player)
+ this.startTime = timeToInt(options.startTime)
+
player.src({
type: options.type,
src: options.src
})
- player.on('play', () => {
+ player.one('play', () => {
player.addClass('vjs-has-big-play-button-clicked')
})
this.statsP2PBytes.numPeers = 1 + this.options.redundancyBaseUrls.length
this.runStats()
+
+ this.hlsjs.on('hlsLevelLoaded', () => {
+ if (this.startTime) this.player.currentTime(this.startTime)
+
+ this.hlsjs.off('hlsLevelLoaded', this)
+ })
}
private runStats () {