Skip to content

Commit

Permalink
[video_player] Calls onDestroy instead of initialize in onDetache…
Browse files Browse the repository at this point in the history
…dFromEngine (#6501)

In the `onDetachedFromEngine` function, the `onDestroy` method should be called instead of the `initialize` method, even though the implementation of the two functions is no different.

```java
  private void onDestroy() {
    // The whole FlutterView is being destroyed. Here we release resources acquired for all
    // instances
    // of VideoPlayer. Once flutter/flutter#19358 is resolved this may
    // be replaced with just asserting that videoPlayers.isEmpty().
    // flutter/flutter#20989 tracks this.
    disposeAllPlayers();
  }

  public void initialize() {
    disposeAllPlayers();
  }
```
  • Loading branch information
0xZOne committed Apr 16, 2024
1 parent 9a24904 commit b2bd8e5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/video_player/video_player_android/CHANGELOG.md
@@ -1,3 +1,7 @@
## 2.4.14

* Calls `onDestroy` instead of `initialize` in onDetachedFromEngine.

## 2.4.13

* Updates minSdkVersion to 19.
Expand Down
Expand Up @@ -95,7 +95,7 @@ public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
}
flutterState.stopListening(binding.getBinaryMessenger());
flutterState = null;
initialize();
onDestroy();
}

private void disposeAllPlayers() {
Expand All @@ -105,7 +105,7 @@ private void disposeAllPlayers() {
videoPlayers.clear();
}

private void onDestroy() {
public void onDestroy() {
// The whole FlutterView is being destroyed. Here we release resources acquired for all
// instances
// of VideoPlayer. Once https://github.com/flutter/flutter/issues/19358 is resolved this may
Expand Down
Expand Up @@ -45,6 +45,6 @@ public void disposeAllPlayers() {

engine.destroy();
verify(videoPlayerPlugin, times(1)).onDetachedFromEngine(pluginBindingCaptor.capture());
verify(videoPlayerPlugin, times(1)).initialize();
verify(videoPlayerPlugin, times(1)).onDestroy();
}
}
2 changes: 1 addition & 1 deletion packages/video_player/video_player_android/pubspec.yaml
Expand Up @@ -2,7 +2,7 @@ name: video_player_android
description: Android implementation of the video_player plugin.
repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
version: 2.4.13
version: 2.4.14

environment:
sdk: ^3.2.0
Expand Down

0 comments on commit b2bd8e5

Please sign in to comment.