aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-20 11:26:14 +0100
committerChocobozzz <me@florianbigard.com>2019-02-20 11:26:14 +0100
commit96cb4527f13f71024d27e2ac0383501b7b3b5a05 (patch)
treeccd2adbb4a0ae13025b1de5dfccc4929d4ce8e26 /client/src/assets
parentb28e4e5e080646ec67363cb0a16c9bd97ccffb35 (diff)
downloadPeerTube-96cb4527f13f71024d27e2ac0383501b7b3b5a05.tar.gz
PeerTube-96cb4527f13f71024d27e2ac0383501b7b3b5a05.tar.zst
PeerTube-96cb4527f13f71024d27e2ac0383501b7b3b5a05.zip
Try to fix p2p-media-loader on ios
Diffstat (limited to 'client/src/assets')
-rw-r--r--client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts8
-rw-r--r--client/src/assets/player/peertube-player-manager.ts19
2 files changed, 19 insertions, 8 deletions
diff --git a/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts b/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts
index 022a9c16f..4dbfda300 100644
--- a/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts
+++ b/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts
@@ -40,6 +40,14 @@ class P2pMediaLoaderPlugin extends Plugin {
40 40
41 this.options = options 41 this.options = options
42 42
43 if (!videojs.Html5Hlsjs) {
44 const message = 'HLS.js does not seem to be supported.'
45 console.warn(message)
46
47 player.ready(() => player.trigger('error', new Error(message)))
48 return
49 }
50
43 videojs.Html5Hlsjs.addHook('beforeinitialize', (videojsPlayer: any, hlsjs: any) => { 51 videojs.Html5Hlsjs.addHook('beforeinitialize', (videojsPlayer: any, hlsjs: any) => {
44 this.hlsjs = hlsjs 52 this.hlsjs = hlsjs
45 }) 53 })
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