openPlayer method

Future<FlutterSoundPlayer?> openPlayer()

Open the Player.

A player must be opened before used. Opening a player takes resources inside the OS. Those resources are freed with the verb closePlayer(). Returns a Future, but the App does not need to wait the completion of this future before doing a startPlayer(). The Future will be automaticaly waited by startPlayer()

On iOS you can pass the enableVoiceProcessing parameter to true to enable the VoiceProcessingIO AudioUnit, this is useful to improving speech audio or VoIP applications.

Example:

    myPlayer = await FlutterSoundPlayer().openPlayer();

    ...
    (do something with myPlayer)
    ...

    await myPlayer.closePlayer();
    myPlayer = null;

Implementation

Future<FlutterSoundPlayer?> openPlayer() async {
  //if (!Platform.isIOS && enableVoiceProcessing) {
  //throw ('VoiceProcessing is only available on iOS');
  //}

  if (_isInited != Initialized.notInitialized) {
    return this;
  }
  Future<FlutterSoundPlayer?>? r;
  await _lock.synchronized(() async {
    r = _openAudioSession();
  });
  return r;
}