preload [2/2]

Preloads music resources.

virtual int preload(agora::util::AString& requestId, int64_t songCode) = 0;

You can call this method to preload the music resources you want to play. After a successful call, the SDK triggers the onPreLoadEvent callback to report the preload event. Before calling this method, you need to call getMusicCollectionByMusicChartId or searchMusic to obtain the target music resources and get the song code (songCode) from the onMusicCollectionResult callback.

Note: Before destroying the IRtcEngine object, make sure you have received the onPreLoadEvent callback before calling the release method.

Parameters

requestId
Output parameter. Request ID used to uniquely identify this request.
songCode
The song code of the music resource, used to identify the music.

Return Values

  • 0: Success.
  • < 0: Failure.