Skip to content

Commit

Permalink
await disposing
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa committed Aug 3, 2023
1 parent da1d3b8 commit de7eab4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/widgets/desktop_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,11 @@ class _WindowButtonsState extends State<WindowButtons> with WindowListener {
// We ensure all the players are disposed in order to not keep the app alive
// in background, wasting unecessary resources!
if (isPreventClose) {
await Future.microtask(() {
windowManager.hide();
await Future.microtask(() async {
for (final player in UnityVideoPlayerInterface.players.toList()) {
debugPrint('Disposing player ${player.hashCode}');
player.dispose();
await player.dispose();
}
});
windowManager.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ class UnityVideoPlayerMediaKit extends UnityVideoPlayer {
}

@override
void dispose() async {
errorStream.cancel();
mkPlayer.dispose();
Future<void> dispose() async {
await errorStream.cancel();
await mkPlayer.dispose();
UnityVideoPlayerInterface.unregisterPlayer(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,5 @@ abstract class UnityVideoPlayer {
Future<void> release();
Future<void> reset();

void dispose();
Future<void> dispose();
}

0 comments on commit de7eab4

Please sign in to comment.