stopAllPlayers method

Future<bool> stopAllPlayers()

Frees resources used by all players simultaneously.

This method closes the stream and releases resources allocated by all players. Note that it does not dispose of the controller.

Returns true if all players stop successfully, otherwise returns false.

Implementation

Future<bool> stopAllPlayers() async {
  PlatformStreams.instance.dispose();
  var isAllPlayersStopped =
      await AudioWaveformsInterface.instance.stopAllPlayers();
  if (isAllPlayersStopped) {
    PlatformStreams.instance.playerControllerFactory
        .forEach((playKey, controller) {
      controller._setPlayerState(PlayerState.stopped);
    });
  }
  return isAllPlayersStopped;
}