preload [1/2]

Preloads music resources.

virtual int preload(int64_t songCode, const char* jsonOption) __deprecated = 0;
Deprecated
This method is deprecated. Please use the preload [2/2] method instead.

You can call this method to preload music resources you want to play. After this method is successfully called, the SDK triggers the onPreLoadEvent callback to report preload events. Before calling this method, you need to call getMusicCollectionWithMusicChartId or searchMusic to obtain the target music resource and get the song code songCode from the onMusicCollectionResult callback.

Note: Before destroying the IRtcEngine object, make sure to call the release method only after receiving the onPreLoadEvent callback.

Parameters

songCode
The song code used to identify the music resource.
jsonOption
Extended JSON field. Agora charges based on the application scenario you pass in the sceneType field. Different scenarios have different billing standards:
  • 1: Live streaming scenario: Online karaoke room and background music playback.
  • 2: Live streaming scenario: Background music playback.
  • 3: (Default) Voice chat scenario: Online karaoke room.
  • 4: Voice chat scenario: Background music playback.
  • 5: VR scenario: Online karaoke room and background music playback.
If you need to switch to another scenario, call this method again and pass the new sceneType value in this field.Example: {"sceneType":1}.

Return Values

  • 0: Success.
  • < 0: Failure.