pauseChannel method
- int channelId
Pauses the sound playing on the specified channelId.
If the channel is not currently playing, this method does nothing. The current playback position is saved so it can be resumed later.
channelId: The ID of the channel to pause.
Implementation
pauseChannel(int channelId) {
var channel = _channels[channelId];
if (channel.state != ChannelState.playing) {
return;
}
channel.offset =
(channel.offset + (audioContext.currentTime - channel.startTime) * channel.rate) %
channel.sound!.buffer!.duration;
channel.sourceNode?.onended = null;
try {
channel.sourceNode?.stop(0);
} catch (e) {
//
}
channel
..sourceNode = null
..state = ChannelState.paused;
}