diff options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/assets/player/p2p-media-loader/hls-plugin.ts | 25 |
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) |