play method

Future<int> play(
  1. int soundId, {
  2. int repeat = 0,
  3. double rate = 1.0,
})

Plays sound identified by soundId

Returns streamId to further control playback or 0 if playing failed to start

web

repeat is ignored. The sound is played only once.

Implementation

Future<int> play(int soundId, {int repeat = 0, double rate = 1.0}) async {
  assert(!_disposed, "Soundpool instance was already disposed");
  assert(
    rate >= 0.5 && rate <= 2.0,
    "'rate' has to be value in (0.5 - 2.0) range",
  );
  assert(soundId > -1,
      "Invalid 'soundId' parameter. Only values greater than -1 are valid.");
  int poolId = await _soundpoolId.future;
  return await _platformInstance.play(poolId, soundId, repeat, rate);
}