paused property Null safety

bool paused
override

Implementation

@override
bool get paused => _paused;
void paused=(bool value)
override

Implementation

@override
set paused(bool value) {
  if (_paused == value) {
    // nothing has changed
  } else if (_stopped) {
    // we can't pause/resume the audio playback.
    _paused = _stopped || value;
  } else if (value) {
    _position = position;
    _paused = true;
    _sourceNodeEndedSubscription?.cancel();
    _sourceNode.stop(0);
  } else if (_loop) {
    _paused = false;
    _sourceNode = WebAudioApiMixer.audioContext.createBufferSource();
    _sourceNode.buffer = _webAudioApiSound._audioBuffer;
    _sourceNode.loop = true;
    _sourceNode.loopStart = _startTime;
    _sourceNode.loopEnd = _startTime + _duration;
    _sourceNode.connectNode(_mixer.inputNode);
    _sourceNode.start(0, _startTime + _position);
    _timeOffset = WebAudioApiMixer.audioContext.currentTime! - _position;
  } else {
    _paused = false;
    _sourceNode = WebAudioApiMixer.audioContext.createBufferSource();
    _sourceNode.buffer = _webAudioApiSound._audioBuffer;
    _sourceNode.loop = false;
    _sourceNode.connectNode(_mixer.inputNode);
    _sourceNode.start(0, _startTime + _position, _duration - _position);
    _sourceNodeEndedSubscription = _sourceNode.onEnded.listen(_onEnded);
    _timeOffset = WebAudioApiMixer.audioContext.currentTime! - _position;
  }
}