dispose method

Future<void> dispose()

Call it to dispose stream

Implementation

Future<void> dispose() async {
  await stop();

  if (_playerEditor != null) {
    playlist?.removeCurrentlyOpenedIn(_playerEditor!);
  }

  await _currentPosition.close();
  await _isPlaying.close();
  await _volume.close();
  await _playlistFinished.close();
  await _current.close();
  await _playlistAudioFinished.close();
  await _audioSessionId.close();
  await _loopMode.close();
  await _shuffle.close();
  await _cacheDownloadInfos.close();
  await _playSpeed.close();
  await _playerState.close();
  await _isBuffering.close();
  await _forwardRewindSpeed.close();
  await _realtimePlayingInfos.close();
  await _realTimeSubscription?.cancel();
  _players.remove(id);

  _playerEditor = null;

  if (_lifecycleObserver != null) {
    WidgetsBinding.instance.removeObserver(_lifecycleObserver!);
    _lifecycleObserver = null;
  }
}