play method

Future<HMSException?> play({
  1. required String fileUrl,
  2. bool loop = false,
  3. bool interrupts = true,
})

The play function on HMSAudioFilePlayerNode to play a file on a local device in a meeting room.

Parameters:

fileUrl - Enter the path of file Refer example App

loop - Play audio in loop. Example background Music

interrupts - Set interrupts parameter to false to tell HMSAudioFilePlayerNode to not interrupt the current file playback, but schedule the file after the current file is finished.

Refer Audio sharing in iOS guide here

Implementation

Future<HMSException?> play(
    {required String fileUrl,
    bool loop = false,
    bool interrupts = true}) async {
  var result = await PlatformService.invokeMethod(
      PlatformMethod.playAudioShare,
      arguments: {
        "name": methodName,
        "file_url": fileUrl,
        "loops": loop,
        "interrupts": interrupts
      });
  if (result["success"]) {
    return null;
  } else {
    return HMSException.fromMap(result["data"]["error"]);
  }
}