startPlayMusic method

Future<bool?> startPlayMusic(
  1. AudioMusicParam musicParam

Start background music

You must assign an ID to each music track, through which you can start, stop, or set the volume of the music track.

Note: to play back multiple music tracks at the same time, assign different IDs to them. If you use the same ID for different music tracks, the SDK cannot play them back at the same time. Instead, it stops playing back the old music track and then starts playing back the new one.


musicParam Music parameter. For more information, please see the definition of the AudioMusicParam parameter in trtc_cloud_def

Returned value:

true: success; false: failure

Platform not supported:

  • web


Future<bool?> startPlayMusic(AudioMusicParam musicParam) {
  return _channel
      .invokeMethod('startPlayMusic', {"musicParam": jsonEncode(musicParam)});