suspend method
Suspends all audio playback (music and sounds).
This is typically called when the application loses focus or becomes inactive. Playing music is paused. Playing sounds are paused and their state is marked as suspended. Records the time of suspension to correctly adjust sound retrigger delays upon resume.
Implementation
suspend() {
if (musicState == ChannelState.playing) {
_music?.pause();
musicState = ChannelState.suspended;
}
for (var i = 0; i < _channels.length; ++i) {
var channel = _channels[i];
if (channel.state == ChannelState.playing) {
pauseChannel(i);
channel.state == ChannelState.suspended;
}
}
_suspendedOn = DateTime.now();
}