close method
Closes the mini window and pauses playback, then notifies onClosed.
Still does not dispose the api — the host decides that in onClosed.
关闭小窗并暂停播放,随后回调 onClosed。
仍然不 dispose api——由宿主在 onClosed 里决定。
Implementation
Future<void> close() async {
final api = _api;
if (api == null) return;
final generation = ++_generation;
_unwatch();
_detachEntry();
_clearWindow();
notifyListeners();
await api.pause();
if (generation != _generation && identical(_api, api)) return;
await api.setMini(false);
if (!_disposed && generation == _generation) onClosed?.call(api);
}