diff --git a/src/players/FilePlayer.js b/src/players/FilePlayer.js index 102b6c95..88a60dc5 100644 --- a/src/players/FilePlayer.js +++ b/src/players/FilePlayer.js @@ -94,6 +94,23 @@ export class FilePlayer extends Component { if (this.shouldUseHLS(url)) { getSDK(HLS_SDK_URL, HLS_GLOBAL).then(Hls => { this.hls = new Hls(this.props.config.file.hlsOptions) + this.hls.on(Hls.Events.ERROR, (e, data) => { + switch (data.type) { + case Hls.ErrorTypes.NETWORK_ERROR: + // try to recover network error + // hls: fatal network error encountered, trying to recover + this.hls.startLoad() + break + case Hls.ErrorTypes.MEDIA_ERROR: + // hls: fatal media error encountered, trying to recover + this.hls.recoverMediaError() + break + default: + // cannot recover + this.hls.destroy() + break + } + }) this.hls.loadSource(url) this.hls.attachMedia(this.player) })