Skip to content

Commit b2bd8e5

Browse files
authored
[video_player] Calls onDestroy instead of initialize in onDetachedFromEngine (#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(); } ```
1 parent 9a24904 commit b2bd8e5

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

packages/video_player/video_player_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.4.14
2+
3+
* Calls `onDestroy` instead of `initialize` in onDetachedFromEngine.
4+
15
## 2.4.13
26

37
* Updates minSdkVersion to 19.

packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
9595
}
9696
flutterState.stopListening(binding.getBinaryMessenger());
9797
flutterState = null;
98-
initialize();
98+
onDestroy();
9999
}
100100

101101
private void disposeAllPlayers() {
@@ -105,7 +105,7 @@ private void disposeAllPlayers() {
105105
videoPlayers.clear();
106106
}
107107

108-
private void onDestroy() {
108+
public void onDestroy() {
109109
// The whole FlutterView is being destroyed. Here we release resources acquired for all
110110
// instances
111111
// of VideoPlayer. Once https://github.com/flutter/flutter/issues/19358 is resolved this may

packages/video_player/video_player_android/example/android/app/src/test/java/io/flutter/plugins/videoplayerexample/FlutterActivityTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ public void disposeAllPlayers() {
4545

4646
engine.destroy();
4747
verify(videoPlayerPlugin, times(1)).onDetachedFromEngine(pluginBindingCaptor.capture());
48-
verify(videoPlayerPlugin, times(1)).initialize();
48+
verify(videoPlayerPlugin, times(1)).onDestroy();
4949
}
5050
}

packages/video_player/video_player_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: video_player_android
22
description: Android implementation of the video_player plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
5-
version: 2.4.13
5+
version: 2.4.14
66

77
environment:
88
sdk: ^3.2.0

0 commit comments

Comments
 (0)