play method

Future<void> play(
  1. AudioPlayer player
)

Implementation

Future<void> play(AudioPlayer player) async {
  if (Platform.isAndroid) {
    final cxt = AudioContext(
      android: const AudioContextAndroid(
        isSpeakerphoneOn: true,
        stayAwake: true,
        audioFocus: AndroidAudioFocus.none,
      ),
    );
    await player.setAudioContext(cxt);
  }
  if (player.source.toString() != _audio?.source.toString()) {
    await _audio?.stop();
  }
  player.setVolume(1);
  await player.resume();
  _audio = player;
  _state = AudioState(
    status: AudioStatus.playing,
    duration: const Duration(),
    position: const Duration(),
    velocity: 1,
    audioId: player.source.toString(),
  );
}