diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-20 11:26:14 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-20 11:26:14 +0100 |
commit | 96cb4527f13f71024d27e2ac0383501b7b3b5a05 (patch) | |
tree | ccd2adbb4a0ae13025b1de5dfccc4929d4ce8e26 /client/src/assets/player/peertube-player-manager.ts | |
parent | b28e4e5e080646ec67363cb0a16c9bd97ccffb35 (diff) | |
download | PeerTube-96cb4527f13f71024d27e2ac0383501b7b3b5a05.tar.gz PeerTube-96cb4527f13f71024d27e2ac0383501b7b3b5a05.tar.zst PeerTube-96cb4527f13f71024d27e2ac0383501b7b3b5a05.zip |
Try to fix p2p-media-loader on ios
Diffstat (limited to 'client/src/assets/player/peertube-player-manager.ts')
-rw-r--r-- | client/src/assets/player/peertube-player-manager.ts | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts index 0ba9bcb11..7631d095f 100644 --- a/client/src/assets/player/peertube-player-manager.ts +++ b/client/src/assets/player/peertube-player-manager.ts | |||
@@ -116,12 +116,8 @@ export class PeertubePlayerManager { | |||
116 | videojs(options.common.playerElement, videojsOptions, function (this: any) { | 116 | videojs(options.common.playerElement, videojsOptions, function (this: any) { |
117 | const player = this | 117 | const player = this |
118 | 118 | ||
119 | player.tech_.on('error', () => { | 119 | player.tech_.one('error', () => self.maybeFallbackToWebTorrent(mode, player, options)) |
120 | // Fallback to webtorrent? | 120 | player.one('error', () => self.maybeFallbackToWebTorrent(mode, player, options)) |
121 | if (mode === 'p2p-media-loader') { | ||
122 | self.fallbackToWebTorrent(player, options) | ||
123 | } | ||
124 | }) | ||
125 | 121 | ||
126 | self.addContextMenu(mode, player, options.common.embedUrl) | 122 | self.addContextMenu(mode, player, options.common.embedUrl) |
127 | 123 | ||
@@ -130,12 +126,19 @@ export class PeertubePlayerManager { | |||
130 | }) | 126 | }) |
131 | } | 127 | } |
132 | 128 | ||
133 | private static async fallbackToWebTorrent (player: any, options: PeertubePlayerManagerOptions) { | 129 | private static async maybeFallbackToWebTorrent (currentMode: PlayerMode, player: any, options: PeertubePlayerManagerOptions) { |
130 | if (currentMode === 'webtorrent') return | ||
131 | |||
132 | console.log('Fallback to webtorrent.') | ||
133 | |||
134 | const newVideoElement = document.createElement('video') | 134 | const newVideoElement = document.createElement('video') |
135 | newVideoElement.className = this.playerElementClassName | 135 | newVideoElement.className = this.playerElementClassName |
136 | 136 | ||
137 | // VideoJS wraps our video element inside a div | 137 | // VideoJS wraps our video element inside a div |
138 | const currentParentPlayerElement = options.common.playerElement.parentNode | 138 | let currentParentPlayerElement = options.common.playerElement.parentNode |
139 | // Fix on IOS, don't ask me why | ||
140 | if (!currentParentPlayerElement) currentParentPlayerElement = document.getElementById(options.common.playerElement.id).parentNode | ||
141 | |||
139 | currentParentPlayerElement.parentNode.insertBefore(newVideoElement, currentParentPlayerElement) | 142 | currentParentPlayerElement.parentNode.insertBefore(newVideoElement, currentParentPlayerElement) |
140 | 143 | ||
141 | options.common.playerElement = newVideoElement | 144 | options.common.playerElement = newVideoElement |