aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-player-manager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/peertube-player-manager.ts')
-rw-r--r--client/src/assets/player/peertube-player-manager.ts14
1 files changed, 14 insertions, 0 deletions
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_ = ' '
43 43
44export class PeertubePlayerManager { 44export class PeertubePlayerManager {
45 private static playerElementClassName: string 45 private static playerElementClassName: string
46 private static playerElementAttributes: { name: string, value: string }[] = []
47
46 private static onPlayerChange: (player: videojs.Player) => void 48 private static onPlayerChange: (player: videojs.Player) => void
47 private static alreadyPlayed = false 49 private static alreadyPlayed = false
48 private static pluginsManager: PluginsManager 50 private static pluginsManager: PluginsManager
@@ -59,8 +61,13 @@ export class PeertubePlayerManager {
59 this.pluginsManager = options.pluginsManager 61 this.pluginsManager = options.pluginsManager
60 62
61 this.onPlayerChange = onPlayerChange 63 this.onPlayerChange = onPlayerChange
64
62 this.playerElementClassName = options.common.playerElement.className 65 this.playerElementClassName = options.common.playerElement.className
63 66
67 for (const name of options.common.playerElement.getAttributeNames()) {
68 this.playerElementAttributes.push({ name, value: options.common.playerElement.getAttribute(name) })
69 }
70
64 if (mode === 'webtorrent') await import('./shared/webtorrent/webtorrent-plugin') 71 if (mode === 'webtorrent') await import('./shared/webtorrent/webtorrent-plugin')
65 if (mode === 'p2p-media-loader') { 72 if (mode === 'p2p-media-loader') {
66 const [ p2pMediaLoaderModule ] = await Promise.all([ 73 const [ p2pMediaLoaderModule ] = await Promise.all([
@@ -216,8 +223,15 @@ export class PeertubePlayerManager {
216 223
217 private static rebuildAndUpdateVideoElement (player: videojs.Player, commonOptions: CommonOptions) { 224 private static rebuildAndUpdateVideoElement (player: videojs.Player, commonOptions: CommonOptions) {
218 const newVideoElement = document.createElement('video') 225 const newVideoElement = document.createElement('video')
226
227 // Reset class
219 newVideoElement.className = this.playerElementClassName 228 newVideoElement.className = this.playerElementClassName
220 229
230 // Reapply attributes
231 for (const { name, value } of this.playerElementAttributes) {
232 newVideoElement.setAttribute(name, value)
233 }
234
221 // VideoJS wraps our video element inside a div 235 // VideoJS wraps our video element inside a div
222 let currentParentPlayerElement = commonOptions.playerElement.parentNode 236 let currentParentPlayerElement = commonOptions.playerElement.parentNode
223 // Fix on IOS, don't ask me why 237 // Fix on IOS, don't ask me why