Skip to content

Commit

Permalink
fix: send error on fatal
Browse files Browse the repository at this point in the history
  • Loading branch information
amar-1995 committed Oct 4, 2023
1 parent 07fc548 commit 5c1912f
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions packages/hls-player/src/controllers/HMSHLSPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,46 +244,48 @@ export class HMSHLSPlayer implements IHMSHLSPlayer, IHMSHLSPlayerEventEmitter {
details: details,
fatal: data.fatal,
};
switch (data.details) {
case Hls.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR: {
const error = HMSHLSErrorFactory.HLSMediaError.manifestIncompatibleCodecsError(detail);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
break;
}
case Hls.ErrorDetails.FRAG_DECRYPT_ERROR: {
const error = HMSHLSErrorFactory.HLSMediaError.fragDecryptError(detail);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
break;
}
case Hls.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR: {
const error = HMSHLSErrorFactory.HLSMediaError.bufferIncompatibleCodecsError(detail);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
break;
}
// Below one are network related errors
case Hls.ErrorDetails.MANIFEST_LOAD_ERROR: {
const error = HMSHLSErrorFactory.HLSNetworkError.manifestLoadError(detail);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
break;
}
case Hls.ErrorDetails.MANIFEST_PARSING_ERROR: {
const error = HMSHLSErrorFactory.HLSNetworkError.manifestParsingError(detail);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
break;
}
case Hls.ErrorDetails.LEVEL_LOAD_ERROR: {
const error = HMSHLSErrorFactory.HLSNetworkError.layerLoadError(detail);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
if (detail.fatal) {
// added reconnection for making player work standalone as well
this.reConnectToStream();
if (detail.fatal) {
switch (data.details) {
case Hls.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR: {
const error = HMSHLSErrorFactory.HLSMediaError.manifestIncompatibleCodecsError(detail);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
break;
}
case Hls.ErrorDetails.FRAG_DECRYPT_ERROR: {
const error = HMSHLSErrorFactory.HLSMediaError.fragDecryptError(detail);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
break;
}
case Hls.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR: {
const error = HMSHLSErrorFactory.HLSMediaError.bufferIncompatibleCodecsError(detail);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
break;
}
// Below one are network related errors
case Hls.ErrorDetails.MANIFEST_LOAD_ERROR: {
const error = HMSHLSErrorFactory.HLSNetworkError.manifestLoadError(detail);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
break;
}
case Hls.ErrorDetails.MANIFEST_PARSING_ERROR: {
const error = HMSHLSErrorFactory.HLSNetworkError.manifestParsingError(detail);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
break;
}
case Hls.ErrorDetails.LEVEL_LOAD_ERROR: {
const error = HMSHLSErrorFactory.HLSNetworkError.layerLoadError(detail);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
if (detail.fatal) {
// added reconnection for making player work standalone as well
this.reConnectToStream();
}
break;
}
default: {
const error = HMSHLSErrorFactory.HLSError(detail, data.type, data.details);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
break;
}
break;
}
default: {
const error = HMSHLSErrorFactory.HLSError(detail, data.type, data.details);
this.emitEvent(HMSHLSPlayerEvents.ERROR, error);
break;
}
}
};
Expand Down

0 comments on commit 5c1912f

Please sign in to comment.