From eaa5dc3161569012188f5ce87099f00e6d0462d5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 31 Oct 2022 13:47:55 +0100 Subject: Reapply playsinline on player fallback --- client/src/assets/player/peertube-player-manager.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'client/src/assets/player/peertube-player-manager.ts') diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts index 9663d90a2..56310c4e9 100644 --- a/client/src/assets/player/peertube-player-manager.ts +++ b/client/src/assets/player/peertube-player-manager.ts @@ -43,6 +43,8 @@ CaptionsButton.prototype.label_ = ' ' export class PeertubePlayerManager { private static playerElementClassName: string + private static playerElementAttributes: { name: string, value: string }[] = [] + private static onPlayerChange: (player: videojs.Player) => void private static alreadyPlayed = false private static pluginsManager: PluginsManager @@ -59,8 +61,13 @@ export class PeertubePlayerManager { this.pluginsManager = options.pluginsManager this.onPlayerChange = onPlayerChange + this.playerElementClassName = options.common.playerElement.className + for (const name of options.common.playerElement.getAttributeNames()) { + this.playerElementAttributes.push({ name, value: options.common.playerElement.getAttribute(name) }) + } + if (mode === 'webtorrent') await import('./shared/webtorrent/webtorrent-plugin') if (mode === 'p2p-media-loader') { const [ p2pMediaLoaderModule ] = await Promise.all([ @@ -216,8 +223,15 @@ export class PeertubePlayerManager { private static rebuildAndUpdateVideoElement (player: videojs.Player, commonOptions: CommonOptions) { const newVideoElement = document.createElement('video') + + // Reset class newVideoElement.className = this.playerElementClassName + // Reapply attributes + for (const { name, value } of this.playerElementAttributes) { + newVideoElement.setAttribute(name, value) + } + // VideoJS wraps our video element inside a div let currentParentPlayerElement = commonOptions.playerElement.parentNode // Fix on IOS, don't ask me why -- cgit v1.2.3