const Plugin: VideoJSComponentInterface = videojs.getPlugin('plugin')
class PeerTubePlugin extends Plugin {
- private readonly autoplay: boolean = false
private readonly startTime: number = 0
private readonly videoViewUrl: string
private readonly videoDuration: number
this.videoDuration = options.videoDuration
this.videoCaptions = options.videoCaptions
- if (this.autoplay === true) this.player.addClass('vjs-has-autoplay')
+ if (options.autoplay === true) this.player.addClass('vjs-has-autoplay')
+
+ this.player.on('autoplay-failure', () => {
+ this.player.removeClass('vjs-has-autoplay')
+ })
this.player.ready(() => {
const playerOptions = this.player.options_
- if (this.player.webtorrent) {
+ if (options.mode === 'webtorrent') {
this.player.webtorrent().on('resolutionChange', (_: any, d: any) => this.handleResolutionChange(d))
this.player.webtorrent().on('autoResolutionChange', (_: any, d: any) => this.trigger('autoResolutionChange', d))
}
- if (this.player.p2pMediaLoader) {
+ if (options.mode === 'p2p-media-loader') {
this.player.p2pMediaLoader().on('resolutionChange', (_: any, d: any) => this.handleResolutionChange(d))
}