aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-09 11:46:16 +0100
committerChocobozzz <me@florianbigard.com>2021-02-09 11:46:30 +0100
commit2d056f6604ab6b5b8dd5ef35e936b89cc6fd48e6 (patch)
tree579253f3acf42d67f012c1830e2b141fe62cfd41 /client/src/assets/player
parent44d1f7f2e8119b8da6a11c3a7b9ef1dd5315d031 (diff)
downloadPeerTube-2d056f6604ab6b5b8dd5ef35e936b89cc6fd48e6.tar.gz
PeerTube-2d056f6604ab6b5b8dd5ef35e936b89cc6fd48e6.tar.zst
PeerTube-2d056f6604ab6b5b8dd5ef35e936b89cc6fd48e6.zip
Try to recover from network errors
Diffstat (limited to 'client/src/assets/player')
-rw-r--r--client/src/assets/player/p2p-media-loader/hls-plugin.ts25
1 files changed, 22 insertions, 3 deletions
diff --git a/client/src/assets/player/p2p-media-loader/hls-plugin.ts b/client/src/assets/player/p2p-media-loader/hls-plugin.ts
index 38a940229..37242befe 100644
--- a/client/src/assets/player/p2p-media-loader/hls-plugin.ts
+++ b/client/src/assets/player/p2p-media-loader/hls-plugin.ts
@@ -236,6 +236,27 @@ class Html5Hlsjs {
236 } 236 }
237 } 237 }
238 238
239 private _handleNetworkError (error: any) {
240 if (this.errorCounts[ Hlsjs.ErrorTypes.NETWORK_ERROR] <= 5) {
241 console.info('trying to recover network error')
242
243 // Wait 1 second and retry
244 setTimeout(() => this.hls.startLoad(), 1000)
245
246 // Reset error count on success
247 this.hls.once(Hlsjs.Events.FRAG_LOADED, () => {
248 this.errorCounts[ Hlsjs.ErrorTypes.NETWORK_ERROR] = 0
249 })
250
251 return
252 }
253
254 console.info('bubbling network error up to VIDEOJS')
255 this.hls.destroy()
256 this.tech.error = () => error
257 this.tech.trigger('error')
258 }
259
239 private _onError (_event: any, data: Hlsjs.errorData) { 260 private _onError (_event: any, data: Hlsjs.errorData) {
240 const error: { message: string, code?: number } = { 261 const error: { message: string, code?: number } = {
241 message: `HLS.js error: ${data.type} - fatal: ${data.fatal} - ${data.details}` 262 message: `HLS.js error: ${data.type} - fatal: ${data.fatal} - ${data.details}`
@@ -249,10 +270,8 @@ class Html5Hlsjs {
249 if (!data.fatal) return 270 if (!data.fatal) return
250 271
251 if (data.type === Hlsjs.ErrorTypes.NETWORK_ERROR) { 272 if (data.type === Hlsjs.ErrorTypes.NETWORK_ERROR) {
252 console.info('bubbling network error up to VIDEOJS')
253 error.code = 2 273 error.code = 2
254 this.tech.error = () => error as any 274 this._handleNetworkError(error)
255 this.tech.trigger('error')
256 } else if (data.type === Hlsjs.ErrorTypes.MEDIA_ERROR && data.details !== 'manifestIncompatibleCodecsError') { 275 } else if (data.type === Hlsjs.ErrorTypes.MEDIA_ERROR && data.details !== 'manifestIncompatibleCodecsError') {
257 error.code = 3 276 error.code = 3
258 this._handleMediaError(error) 277 this._handleMediaError(error)