`playerState`, `isPlaying`, `isPaused`, `isStopped`. `getPlayerState()`

The τ Player API


playerState, isPlaying, isPaused, isStopped. getPlayerState()

This four verbs is used when the app wants to get the current Audio State of the player.

playerState is an attribut which can have the following values :

  • isStopped /// Player is stopped
  • isPlaying /// Player is playing
  • isPaused /// Player is paused

  • isPlaying is a boolean attribut which is true when the player is in the “Playing” mode.
  • isPaused is a boolean atrribut which is true when the player is in the “Paused” mode.
  • isStopped is a boolean atrribut which is true when the player is in the “Stopped” mode.

Flutter Sound shows in the playerState attribut the last known state. When the Audio State of the background OS engine changes, the playerState parameter is not updated exactly at the same time. If you want the exact background OS engine state you must use PlayerState theState = await myPlayer.getPlayerState(). Acutually getPlayerState() is only implemented on iOS.

Example:

        swtich(myPlayer.playerState)
        {
                case PlayerState.isPlaying: doSomething; break;
                case PlayerState.isStopped: doSomething; break;
                case PlayerState.isPaused: doSomething; break;
        }
        ...
        if (myPlayer.isStopped) doSomething;
        if (myPlayer.isPlaying) doSomething;
        if (myPlayer.isPaused) doSomething;
        ...
        PlayerState theState = await myPlayer.getPlayerState();
        ...
        Lorem ipsum ...

Tags: api player