playMusic method

FutureOr<void> playMusic(
  1. NSString musicId,
  2. ByteRTCAudioTrackType trackType,
  3. ByteRTCAudioPlayType playType
)

@detail api @author lihuan.wuti2ha @brief Plays the music. @param musicId Music ID.
If the song with the same musicId is playing when you call this API, the music will restart from the starting position. An error will be triggered if the audio file corresponding to musicId does not exist. @param trackType Audio track type of the KTV player. See ByteRTCAudioTrackType{@link #ByteRTCAudioTrackType}. @param playType Audio play type. See ByteRTCAudioPlayType{@link #ByteRTCAudioPlayType}. @note - After calling this API, you will receive the music play state through ktvPlayer:onPlayStateChanged:state:error:{@link #ByteRTCKTVPlayerDelegate#ktvPlayer:onPlayStateChanged:state:error} callback. - If the music ID is invalid, you will receive the ktvPlayer:onPlayStateChanged:state:error:{@link #ByteRTCKTVPlayerDelegate#ktvPlayer:onPlayStateChanged:state:error} callback, with an errorCode of -3023 and a playState of 4. - If you didn't join the room, you will receive the ktvPlayer:onPlayStateChanged:state:error:{@link #ByteRTCKTVPlayerDelegate#ktvPlayer:onPlayStateChanged:state:error} callback, with an errorCode of -3022 and a playState of 4. - If the music file does not exist, you will receive the ktvPlayer:onPlayStateChanged:state:error:{@link #ByteRTCKTVPlayerDelegate#ktvPlayer:onPlayStateChanged:state:error} callback, with an errorCode of -3020 and a playState of 4.

Implementation

FutureOr<void> playMusic(NSString musicId, ByteRTCAudioTrackType trackType,
    ByteRTCAudioPlayType playType) async {
  return await nativeCall('playMusic:audioTrackType:audioPlayType:',
      [musicId, trackType.$value, playType.$value]);
}