dispose method
Dispose PipFlutterPlayerController. When forceDispose
parameter is true, then
autoDispose parameter will be overridden and controller will be disposed
(if it wasn't disposed before).
Implementation
void dispose({bool forceDispose = false}) {
if (!pipFlutterPlayerConfiguration.autoDispose && !forceDispose) {
return;
}
if (!_disposed) {
if (videoPlayerController != null) {
pause();
videoPlayerController!.removeListener(_onFullScreenStateChanged);
videoPlayerController!.removeListener(_onVideoPlayerChanged);
videoPlayerController!.dispose();
}
_eventListeners.clear();
_nextVideoTimer?.cancel();
_nextVideoTimeStreamController.close();
_controlsVisibilityStreamController.close();
_videoEventStreamSubscription?.cancel();
_disposed = true;
_controllerEventStreamController.close();
///Delete files async
_tempFiles.forEach((file) => file.delete());
}
}