dispose method

void dispose()

Dispose the controller and release resources

Implementation

void dispose() {
  if (_isDisposed) return;
  _isDisposed = true;

  // Cancel all subscriptions first
  for (final subscription in _subscriptions) {
    subscription.cancel();
  }
  _subscriptions.clear();

  // Then close the controllers
  _playbackStateController.close();
  _durationStateController.close();
  _downloadStateController.close();
  _downloadProgressController.close();
  _loadingController.close();
  _subtitleController.close();

  if (_isInitialized) {
    _playerMethodManager.dispose();
  }
}