closeMedia method
- {required BuildContext context,
- required WidgetRef ref,
- required MediaSource mediaSource,
- MediaItem? item}
Ends a media session and ensures that values are reset.
Implementation
Future<void> closeMedia({
required BuildContext context,
required WidgetRef ref,
required MediaSource mediaSource,
MediaItem? item,
}) async {
mediaSource.setShouldGenerateImage(value: true);
mediaSource.setShouldGenerateAudio(value: true);
mediaSource.clearCurrentSentence();
mediaSource.clearExtraData();
_currentMediaSource = null;
_currentMediaItem = null;
_overrideDictionaryColor = null;
_overrideDictionaryTheme = null;
blockCreatorInitialMedia = false;
isProcessingEmbeddedSubtitles = false;
await Wakelock.disable();
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
await mediaSource.onSourceExit(
appModel: this,
context: context,
ref: ref,
);
await _audioHandler?.stop();
mediaSource.mediaType.refreshTab();
DictionaryMediaType.instance.refreshTab();
if (_shouldKillMediaOnPop) {
shutdown();
}
}