stopMusic method

void stopMusic()

Stops the currently playing or paused music.

If no music is active (playing, paused), this method does nothing. Disconnects the AudioVisualizer if one was active for the music. Resets music position and clears the loaded music.

Implementation

void stopMusic() {
  if (musicState == ChannelState.stopped) {
    return;
  }

  _musicVisualizer?.disconnect();

  _music?.pause();
  _music = null;

  musicState = ChannelState.stopped;

  _playPromise = null;
}