pauseMusic method
Pauses the currently playing music.
If music is not playing, this method does nothing. The current playback position is maintained.
Implementation
void pauseMusic() {
if (musicState != ChannelState.playing) {
return;
}
if (_playPromise != null) {
_playPromise!
.then((_) {
if (_music != null) {
_music!.pause();
musicState = ChannelState.paused;
}
_playPromise = null;
})
.catchError((e) {});
} else {
_music?.pause();
musicState = ChannelState.paused;
}
}