From bf1a0692bce4a37f0e5f2e658f99d069607b49bd Mon Sep 17 00:00:00 2001 From: maRci002 Date: Fri, 3 Mar 2023 15:28:12 +0100 Subject: [PATCH 1/5] add VideoEventType.isPlayingStateUpdate event --- .../video_player_platform_interface/AUTHORS | 1 + .../CHANGELOG.md | 5 +++++ .../lib/video_player_platform_interface.dart | 20 +++++++++++++++++-- .../pubspec.yaml | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/AUTHORS b/packages/video_player/video_player_platform_interface/AUTHORS index 493a0b4ef9c..fc16c35c4c2 100644 --- a/packages/video_player/video_player_platform_interface/AUTHORS +++ b/packages/video_player/video_player_platform_interface/AUTHORS @@ -64,3 +64,4 @@ Aleksandr Yurkovskiy Anton Borries Alex Li Rahul Raj <64.rahulraj@gmail.com> +Márton Matuz diff --git a/packages/video_player/video_player_platform_interface/CHANGELOG.md b/packages/video_player/video_player_platform_interface/CHANGELOG.md index ba7e9370d01..f332d61b183 100644 --- a/packages/video_player/video_player_platform_interface/CHANGELOG.md +++ b/packages/video_player/video_player_platform_interface/CHANGELOG.md @@ -1,3 +1,8 @@ +## 6.0.3 + +* Add the `VideoEventType.isPlayingStateUpdate` event to track changes in play / pause state with + the underlying video player. + ## 6.0.2 * Updates links for the merge of flutter/plugins into flutter/packages. diff --git a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart index d3df9b25df5..11af62b88de 100644 --- a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart +++ b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart @@ -212,6 +212,7 @@ class VideoEvent { this.size, this.rotationCorrection, this.buffered, + this.isPlaying, }); /// The type of the event. @@ -237,6 +238,11 @@ class VideoEvent { /// Only used if [eventType] is [VideoEventType.bufferingUpdate]. final List? buffered; + /// Play state changed. + /// + /// Only used if [eventType] is [VideoEventType.isPlayingStateUpdate]. + final bool? isPlaying; + @override bool operator ==(Object other) { return identical(this, other) || @@ -246,7 +252,8 @@ class VideoEvent { duration == other.duration && size == other.size && rotationCorrection == other.rotationCorrection && - listEquals(buffered, other.buffered); + listEquals(buffered, other.buffered) && + isPlaying == other.isPlaying; } @override @@ -256,13 +263,14 @@ class VideoEvent { size, rotationCorrection, buffered, + isPlaying, ); } /// Type of the event. /// /// Emitted by the platform implementation when the video is initialized or -/// completed or to communicate buffering events. +/// completed or to communicate buffering events or play state changed. enum VideoEventType { /// The video has been initialized. initialized, @@ -279,6 +287,14 @@ enum VideoEventType { /// The video stopped to buffer. bufferingEnd, + /// Represents an event type emitted by the platform implementation when the + /// video playback state is updated, for example, when the video starts or + /// pauses due to user actions or phone calls, or other app media such as + /// music players. + /// Note that when [VideoPlayerOptions.mixWithOthers] is true, the video may + /// continue playing even during a phone call. + isPlayingStateUpdate, + /// An unknown event has been received. unknown, } diff --git a/packages/video_player/video_player_platform_interface/pubspec.yaml b/packages/video_player/video_player_platform_interface/pubspec.yaml index a75d05a156d..e92076a0f17 100644 --- a/packages/video_player/video_player_platform_interface/pubspec.yaml +++ b/packages/video_player/video_player_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/video_player/ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 6.0.2 +version: 6.0.3 environment: sdk: ">=2.12.0 <3.0.0" From 4dce6d35857e767f7a70f53527ae361a07f76ac1 Mon Sep 17 00:00:00 2001 From: maRci002 Date: Fri, 3 Mar 2023 19:25:09 +0100 Subject: [PATCH 2/5] apply requested changes --- .../video_player_platform_interface/CHANGELOG.md | 2 +- .../lib/video_player_platform_interface.dart | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/CHANGELOG.md b/packages/video_player/video_player_platform_interface/CHANGELOG.md index f332d61b183..eb1e31277d7 100644 --- a/packages/video_player/video_player_platform_interface/CHANGELOG.md +++ b/packages/video_player/video_player_platform_interface/CHANGELOG.md @@ -1,6 +1,6 @@ ## 6.0.3 -* Add the `VideoEventType.isPlayingStateUpdate` event to track changes in play / pause state with +* Adds the `VideoEventType.isPlayingStateUpdate` event to track changes in play / pause state with the underlying video player. ## 6.0.2 diff --git a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart index 11af62b88de..32410660ce8 100644 --- a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart +++ b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart @@ -238,7 +238,7 @@ class VideoEvent { /// Only used if [eventType] is [VideoEventType.bufferingUpdate]. final List? buffered; - /// Play state changed. + /// Whether the video is currently playing. /// /// Only used if [eventType] is [VideoEventType.isPlayingStateUpdate]. final bool? isPlaying; @@ -287,12 +287,10 @@ enum VideoEventType { /// The video stopped to buffer. bufferingEnd, - /// Represents an event type emitted by the platform implementation when the - /// video playback state is updated, for example, when the video starts or - /// pauses due to user actions or phone calls, or other app media such as - /// music players. - /// Note that when [VideoPlayerOptions.mixWithOthers] is true, the video may - /// continue playing even during a phone call. + /// The playback state of the video has changed. + /// + /// This event is fired when the video starts or pauses due to user actions or + /// phone calls, or other app media such as music players. isPlayingStateUpdate, /// An unknown event has been received. From 18f5399832d59de9e84fb23dce9731c48a538bd7 Mon Sep 17 00:00:00 2001 From: maRci002 Date: Tue, 7 Mar 2023 23:19:50 +0100 Subject: [PATCH 3/5] Bump up minor version --- .../video_player/video_player_platform_interface/CHANGELOG.md | 2 +- .../video_player/video_player_platform_interface/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/CHANGELOG.md b/packages/video_player/video_player_platform_interface/CHANGELOG.md index 3f79b5628b0..55b3f5cffde 100644 --- a/packages/video_player/video_player_platform_interface/CHANGELOG.md +++ b/packages/video_player/video_player_platform_interface/CHANGELOG.md @@ -1,4 +1,4 @@ -## 6.0.3 +## 6.1.0 * Aligns Dart and Flutter SDK constraints. * Adds the `VideoEventType.isPlayingStateUpdate` event to track changes in play / pause state with diff --git a/packages/video_player/video_player_platform_interface/pubspec.yaml b/packages/video_player/video_player_platform_interface/pubspec.yaml index 6eaf039f96b..7a49748e9da 100644 --- a/packages/video_player/video_player_platform_interface/pubspec.yaml +++ b/packages/video_player/video_player_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/video_player/ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 6.0.3 +version: 6.1.0 environment: sdk: ">=2.17.0 <3.0.0" From e68d23ae96ad438636ef707bf1da92cd6e6f60ea Mon Sep 17 00:00:00 2001 From: maRci002 Date: Tue, 7 Mar 2023 23:31:32 +0100 Subject: [PATCH 4/5] ignore missing_enum_constant_in_switch lint --- packages/video_player/video_player/lib/video_player.dart | 1 + .../video_player_android/example/lib/mini_controller.dart | 1 + .../video_player_avfoundation/example/lib/mini_controller.dart | 1 + 3 files changed, 3 insertions(+) diff --git a/packages/video_player/video_player/lib/video_player.dart b/packages/video_player/video_player/lib/video_player.dart index 2b5c6252c9d..99ce2325400 100644 --- a/packages/video_player/video_player/lib/video_player.dart +++ b/packages/video_player/video_player/lib/video_player.dart @@ -369,6 +369,7 @@ class VideoPlayerController extends ValueNotifier { return; } + // ignore: missing_enum_constant_in_switch switch (event.eventType) { case VideoEventType.initialized: value = value.copyWith( diff --git a/packages/video_player/video_player_android/example/lib/mini_controller.dart b/packages/video_player/video_player_android/example/lib/mini_controller.dart index 3ad1b6a4b73..55f08fef3c6 100644 --- a/packages/video_player/video_player_android/example/lib/mini_controller.dart +++ b/packages/video_player/video_player_android/example/lib/mini_controller.dart @@ -219,6 +219,7 @@ class MiniController extends ValueNotifier { final Completer initializingCompleter = Completer(); void eventListener(VideoEvent event) { + // ignore: missing_enum_constant_in_switch switch (event.eventType) { case VideoEventType.initialized: value = value.copyWith( diff --git a/packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart b/packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart index 3ad1b6a4b73..55f08fef3c6 100644 --- a/packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart +++ b/packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart @@ -219,6 +219,7 @@ class MiniController extends ValueNotifier { final Completer initializingCompleter = Completer(); void eventListener(VideoEvent event) { + // ignore: missing_enum_constant_in_switch switch (event.eventType) { case VideoEventType.initialized: value = value.copyWith( From 6e4aa1d2b6594bccc725cc4e1b8b8c82eed43807 Mon Sep 17 00:00:00 2001 From: maRci002 Date: Fri, 10 Mar 2023 18:01:26 +0100 Subject: [PATCH 5/5] remove missing_enum_constant_in_switch --- packages/video_player/video_player/lib/video_player.dart | 1 - .../video_player_android/example/lib/mini_controller.dart | 1 - .../video_player_avfoundation/example/lib/mini_controller.dart | 1 - 3 files changed, 3 deletions(-) diff --git a/packages/video_player/video_player/lib/video_player.dart b/packages/video_player/video_player/lib/video_player.dart index 99ce2325400..2b5c6252c9d 100644 --- a/packages/video_player/video_player/lib/video_player.dart +++ b/packages/video_player/video_player/lib/video_player.dart @@ -369,7 +369,6 @@ class VideoPlayerController extends ValueNotifier { return; } - // ignore: missing_enum_constant_in_switch switch (event.eventType) { case VideoEventType.initialized: value = value.copyWith( diff --git a/packages/video_player/video_player_android/example/lib/mini_controller.dart b/packages/video_player/video_player_android/example/lib/mini_controller.dart index 55f08fef3c6..3ad1b6a4b73 100644 --- a/packages/video_player/video_player_android/example/lib/mini_controller.dart +++ b/packages/video_player/video_player_android/example/lib/mini_controller.dart @@ -219,7 +219,6 @@ class MiniController extends ValueNotifier { final Completer initializingCompleter = Completer(); void eventListener(VideoEvent event) { - // ignore: missing_enum_constant_in_switch switch (event.eventType) { case VideoEventType.initialized: value = value.copyWith( diff --git a/packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart b/packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart index 55f08fef3c6..3ad1b6a4b73 100644 --- a/packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart +++ b/packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart @@ -219,7 +219,6 @@ class MiniController extends ValueNotifier { final Completer initializingCompleter = Completer(); void eventListener(VideoEvent event) { - // ignore: missing_enum_constant_in_switch switch (event.eventType) { case VideoEventType.initialized: value = value.copyWith(