playBytes method

Future<AudioPlayer> playBytes(
  1. Uint8List fileBytes, {
  2. double volume = 1.0,
  3. bool? isNotification,
  4. PlayerMode mode = PlayerMode.MEDIA_PLAYER,
  5. bool loop = false,
  6. bool? stayAwake,
  7. bool? recordingActive,
})

Plays the given fileName by a byte source.

This is no different than calling this API via AudioPlayer, except it will return (if applicable) the cached AudioPlayer.

Implementation

Future<AudioPlayer> playBytes(
  Uint8List fileBytes, {
  double volume = 1.0,
  bool? isNotification,
  PlayerMode mode = PlayerMode.MEDIA_PLAYER,
  bool loop = false,
  bool? stayAwake,
  bool? recordingActive,
}) async {
  AudioPlayer player = _player(mode);

  if (loop) {
    player.setReleaseMode(ReleaseMode.LOOP);
  }

  await player.playBytes(
    fileBytes,
    volume: volume,
    respectSilence: isNotification ?? respectSilence,
    stayAwake: stayAwake,
    recordingActive: recordingActive,
  );
  return player;
}