TRTCMusicEvent

TRTCMusicEvent

Music event

Type Definitions

onStart(idopt, errCodeopt)

Parameters:
Name Type Description
id Number

Background music ID

errCode Number

0: Start playing successfully; -4001: Failed to open the file, such as the audio file format is not supported, the local audio file does not exist, the network audio file cannot be accessed, etc.

onPlayProgress(idopt, curPtsMSopt, durationMSopt)

Parameters:
Name Type Description
id Number

Background music ID

curPtsMS Number

current playing timestamp in ms

durationMS Number

music duration time in ms

onComplete(idopt, errCodeopt)

Parameters:
Name Type Description
id Number

Background music ID

errCode Number

0: End of play; -4002: Decoding failure, such as audio file corruption, inaccessible network audio file server, etc.

onLoadProgress(idopt, progressopt)

Parameters:
Name Type Description
id Number

Background music ID

progress Number

Loading progress

onLoadError(idopt, errorCodeopt)

Parameters:
Name Type Description
id Number

Background music ID

errorCode Number

errorCode

  • -4001: Failed to open file, such as invalid audio data, FFMPEG protocol not found, etc.;
  • -4002: Decoding failed, such as audio file corruption, network audio file server cannot be accessed, etc.;
  • -4003: The number of preloads exceeds the limit, please call stopPlayMusic first to release unnecessary preloads;
  • -4005: An illegal path causes the file to fail to open, please check whether the path parameter you passed points to a legal music file;
  • -4006: An illegal URL causes the file to fail to open, please use a browser to check whether the URL address you entered can download the expected music file;
  • -4007: No audio stream causes the file to fail to open, please confirm whether the file you passed is a legal audio file and whether the file is damaged;
  • -4008: Unsupported format causes the file to fail to open, please confirm whether the file format you passed is a supported file format, mobile terminal supports【mp3, aac, m4a, wav, ogg, mp4, mkv】, desktop terminal supports【mp3, aac, m4a, wav, mp4, mkv】.