`openPlayer()` and `closePlayer()`.

The τ Player API

openPlayer() and closePlayer()

A player must be opened before used. Opening a player takes resources inside the OS. Those resources are freed with the verb closePlayer(). It is safe to call this procedure at any time.

  • If the Player is not open, this verb will do nothing
  • If the Player is currently in play or pause mode, it will be stopped before.
void dispose()
        if (myPlayer != null)
            myPlayer = null;

You may not open many Audio Sessions without closing them.

openPlayer() and closePlayer() return Futures. You may not use your Player before the end of the initialization. So probably you will await the result of openPlayer(). This result is the Player itself, so that you can collapse instanciation and initialization together with myPlayer = await FlutterSoundPlayer().openAudioSession();


    FlutterSoundPlayer myPlayer = FlutterSoundPlayer();
    myPlayer = await FlutterSoundPlayer().openPlayer();

    (do something with myPlayer)

    await myPlayer.closePlayer();
    myPlayer = null;
        Lorem ipsum ...

Tags: api player