From 59a643aa5cf6775d27dfcc147b19c4537292d53c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 15 Nov 2022 11:57:49 +0100 Subject: Force autoplay when live starts Using the mute --- .../player/shared/manager-options/manager-options-builder.ts | 8 ++++++-- client/src/assets/player/shared/peertube/peertube-plugin.ts | 2 +- client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'client/src/assets/player/shared') diff --git a/client/src/assets/player/shared/manager-options/manager-options-builder.ts b/client/src/assets/player/shared/manager-options/manager-options-builder.ts index 2d96c9410..4d227eb2a 100644 --- a/client/src/assets/player/shared/manager-options/manager-options-builder.ts +++ b/client/src/assets/player/shared/manager-options/manager-options-builder.ts @@ -105,10 +105,12 @@ export class ManagerOptionsBuilder { Object.assign(videojsOptions, { language: commonOptions.language }) } + console.log(videojsOptions) + return videojsOptions } - private getAutoPlayValue (autoplay: any, alreadyPlayed: boolean) { + private getAutoPlayValue (autoplay: videojs.Autoplay, alreadyPlayed: boolean) { if (autoplay !== true) return autoplay // On first play, disable autoplay to avoid issues @@ -117,7 +119,9 @@ export class ManagerOptionsBuilder { return alreadyPlayed ? 'play' : false } - return 'play' + return this.options.common.forceAutoplay + ? 'any' + : 'play' } getContextMenuOptions (player: videojs.Player, commonOptions: CommonOptions) { diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts index 56de66998..ec8fbb320 100644 --- a/client/src/assets/player/shared/peertube/peertube-plugin.ts +++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts @@ -52,7 +52,7 @@ class PeerTubePlugin extends Plugin { this.videoCaptions = options.videoCaptions this.initialInactivityTimeout = this.player.options_.inactivityTimeout - if (options.autoplay) this.player.addClass('vjs-has-autoplay') + if (options.autoplay !== false) this.player.addClass('vjs-has-autoplay') this.player.on('autoplay-failure', () => { this.player.removeClass('vjs-has-autoplay') diff --git a/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts index 658b7c867..46d009410 100644 --- a/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts +++ b/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts @@ -25,7 +25,7 @@ class WebTorrentPlugin extends Plugin { private readonly playerElement: HTMLVideoElement - private readonly autoplay: boolean = false + private readonly autoplay: boolean | string = false private readonly startTime: number = 0 private readonly savePlayerSrcFunction: videojs.Player['src'] private readonly videoDuration: number @@ -449,7 +449,7 @@ class WebTorrentPlugin extends Plugin { return } - if (this.autoplay) { + if (this.autoplay !== false) { this.player.posterImage.hide() return this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime }) -- cgit v1.2.3