dispose method

  1. @override
void dispose()
override

Release any resources taken by this controller. Disposing this will stop the player and release resources from native.

If this is last remaining controller then it will also dispose the platform stream. They can be re-initialised by initialising a new controller.

Implementation

@override
void dispose() async {
  if (playerState != PlayerState.stopped) await stopPlayer();
  await release();
  PlatformStreams.instance.playerControllerFactory.remove(playerKey);
  if (PlatformStreams.instance.playerControllerFactory.isEmpty) {
    PlatformStreams.instance.dispose();
  }
  _isDisposed = true;
  super.dispose();
}