aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts')
-rw-r--r--client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts45
1 files changed, 33 insertions, 12 deletions
diff --git a/client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts b/client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts
index e49e5c694..a14beb347 100644
--- a/client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts
+++ b/client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts
@@ -211,6 +211,28 @@ class Html5Hlsjs {
211 } 211 }
212 } 212 }
213 213
214 private _getHumanErrorMsg (error: { message: string, code?: number }) {
215 switch (error.code) {
216 default:
217 return error.message
218 }
219 }
220
221 private _handleUnrecovarableError (error: any) {
222 if (this.hls.levels.filter(l => l.id > -1).length > 1) {
223 this._removeQuality(this.hls.loadLevel)
224 return
225 }
226
227 this.hls.destroy()
228 logger.info('bubbling error up to VIDEOJS')
229 this.tech.error = () => ({
230 ...error,
231 message: this._getHumanErrorMsg(error)
232 })
233 this.tech.trigger('error')
234 }
235
214 private _handleMediaError (error: any) { 236 private _handleMediaError (error: any) {
215 if (this.errorCounts[Hlsjs.ErrorTypes.MEDIA_ERROR] === 1) { 237 if (this.errorCounts[Hlsjs.ErrorTypes.MEDIA_ERROR] === 1) {
216 logger.info('trying to recover media error') 238 logger.info('trying to recover media error')
@@ -226,14 +248,13 @@ class Html5Hlsjs {
226 } 248 }
227 249
228 if (this.errorCounts[Hlsjs.ErrorTypes.MEDIA_ERROR] > 2) { 250 if (this.errorCounts[Hlsjs.ErrorTypes.MEDIA_ERROR] > 2) {
229 logger.info('bubbling media error up to VIDEOJS') 251 this._handleUnrecovarableError(error)
230 this.hls.destroy()
231 this.tech.error = () => error
232 this.tech.trigger('error')
233 } 252 }
234 } 253 }
235 254
236 private _handleNetworkError (error: any) { 255 private _handleNetworkError (error: any) {
256 if (navigator.onLine === false) return
257
237 if (this.errorCounts[Hlsjs.ErrorTypes.NETWORK_ERROR] <= this.maxNetworkErrorRecovery) { 258 if (this.errorCounts[Hlsjs.ErrorTypes.NETWORK_ERROR] <= this.maxNetworkErrorRecovery) {
238 logger.info('trying to recover network error') 259 logger.info('trying to recover network error')
239 260
@@ -248,10 +269,7 @@ class Html5Hlsjs {
248 return 269 return
249 } 270 }
250 271
251 logger.info('bubbling network error up to VIDEOJS') 272 this._handleUnrecovarableError(error)
252 this.hls.destroy()
253 this.tech.error = () => error
254 this.tech.trigger('error')
255 } 273 }
256 274
257 private _onError (_event: any, data: ErrorData) { 275 private _onError (_event: any, data: ErrorData) {
@@ -273,10 +291,7 @@ class Html5Hlsjs {
273 error.code = 3 291 error.code = 3
274 this._handleMediaError(error) 292 this._handleMediaError(error)
275 } else if (data.fatal) { 293 } else if (data.fatal) {
276 this.hls.destroy() 294 this._handleUnrecovarableError(error)
277 logger.info('bubbling error up to VIDEOJS')
278 this.tech.error = () => error as any
279 this.tech.trigger('error')
280 } 295 }
281 } 296 }
282 297
@@ -292,6 +307,12 @@ class Html5Hlsjs {
292 return '0' 307 return '0'
293 } 308 }
294 309
310 private _removeQuality (index: number) {
311 this.hls.removeLevel(index)
312 this.player.peertubeResolutions().remove(index)
313 this.hls.currentLevel = -1
314 }
315
295 private _notifyVideoQualities () { 316 private _notifyVideoQualities () {
296 if (!this.metadata) return 317 if (!this.metadata) return
297 318