open

Opens a music resource using the song code.

virtual int open(int64_t songCode, int64_t startPos = 0) = 0;

Before calling this method, make sure the music resource to be played is already loaded. You can call isPreloaded to check whether the resource is preloaded, or listen for the onPreLoadEvent callback. After calling this method, the SDK triggers the onPlayerSourceStateChanged callback. Once you receive the PLAYER_STATE_OPEN_COMPLETED playback state, you can call the play method to play the media file.

Note: If the music resource to be opened is protected by Digital Rights Management (DRM), you must use this method to open it. For resources not protected by DRM, you can choose to use this method or the open method to open them.

Parameters

songCode
The song code of the music resource, used to identify the music.
startPos
The start position for playback, in milliseconds. The default value is 0.

Return Values

  • 0: Success.
  • < 0: Failure.