From 21f27e91a51d6580d4d1eb39c5bdc923e538efca Mon Sep 17 00:00:00 2001 From: maRci002 Date: Wed, 22 Feb 2023 17:29:49 +0100 Subject: [PATCH 01/15] Recreating PR from flutter/plugins --- packages/video_player/video_player/AUTHORS | 1 + .../video_player/video_player/CHANGELOG.md | 3 +- .../video_player/example/pubspec.yaml | 5 ++ .../lib/src/closed_caption_file.dart | 21 ++++++- .../video_player/lib/video_player.dart | 56 ++++++++++++++++--- .../video_player/video_player/pubspec.yaml | 13 ++++- .../video_player/test/video_player_test.dart | 47 ++++++++-------- .../video_player/video_player_android/AUTHORS | 1 + .../video_player_android/CHANGELOG.md | 3 +- .../plugins/videoplayer/VideoPlayer.java | 10 ++++ .../example/lib/mini_controller.dart | 45 +++++++++++++-- .../video_player_android/example/pubspec.yaml | 5 ++ .../lib/src/android_video_player.dart | 5 ++ .../video_player_android/pubspec.yaml | 7 ++- .../test/android_video_player_test.dart | 45 ++++++++++++--- .../video_player_avfoundation/AUTHORS | 1 + .../video_player_avfoundation/CHANGELOG.md | 3 +- .../example/lib/mini_controller.dart | 45 +++++++++++++-- .../example/pubspec.yaml | 5 ++ .../ios/Classes/FLTVideoPlayerPlugin.m | 20 ++++++- .../lib/src/avfoundation_video_player.dart | 5 ++ .../video_player_avfoundation/pubspec.yaml | 7 ++- .../test/avfoundation_video_player_test.dart | 43 ++++++++++++-- .../video_player_platform_interface/AUTHORS | 1 + .../CHANGELOG.md | 4 +- .../lib/video_player_platform_interface.dart | 20 ++++++- .../pubspec.yaml | 2 +- .../video_player/video_player_web/AUTHORS | 1 + .../video_player_web/CHANGELOG.md | 3 +- .../video_player_web_test.dart | 50 ++++++++++++++--- .../video_player_web/example/pubspec.yaml | 5 ++ .../lib/src/video_player.dart | 14 +++++ .../video_player_web/pubspec.yaml | 7 ++- 33 files changed, 426 insertions(+), 77 deletions(-) diff --git a/packages/video_player/video_player/AUTHORS b/packages/video_player/video_player/AUTHORS index 02a9c690f33..e57e00b47c8 100644 --- a/packages/video_player/video_player/AUTHORS +++ b/packages/video_player/video_player/AUTHORS @@ -65,3 +65,4 @@ Anton Borries Alex Li Rahul Raj <64.rahulraj@gmail.com> Koen Van Looveren +Márton Matuz diff --git a/packages/video_player/video_player/CHANGELOG.md b/packages/video_player/video_player/CHANGELOG.md index eed3b6bc234..15e589e6e37 100644 --- a/packages/video_player/video_player/CHANGELOG.md +++ b/packages/video_player/video_player/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 2.5.2 +* Synchronizes `VideoPlayerValue.isPlaying` with underlying video player. * Updates minimum Flutter version to 3.0. ## 2.5.1 diff --git a/packages/video_player/video_player/example/pubspec.yaml b/packages/video_player/video_player/example/pubspec.yaml index 0b30e9fb01e..2e100859c1d 100644 --- a/packages/video_player/video_player/example/pubspec.yaml +++ b/packages/video_player/video_player/example/pubspec.yaml @@ -37,3 +37,8 @@ flutter: - assets/bumble_bee_captions.srt - assets/bumble_bee_captions.vtt - assets/Audio.mp3 + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../../video_player_platform_interface \ No newline at end of file diff --git a/packages/video_player/video_player/lib/src/closed_caption_file.dart b/packages/video_player/video_player/lib/src/closed_caption_file.dart index 324ffc471ff..91b44687d7d 100644 --- a/packages/video_player/video_player/lib/src/closed_caption_file.dart +++ b/packages/video_player/video_player/lib/src/closed_caption_file.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/foundation.dart' show objectRuntimeType; +import 'package:flutter/foundation.dart' show immutable, objectRuntimeType; import 'sub_rip.dart'; import 'web_vtt.dart'; @@ -32,6 +32,7 @@ abstract class ClosedCaptionFile { /// /// A typical closed captioning file will include several [Caption]s, each /// linked to a start and end time. +@immutable class Caption { /// Creates a new [Caption] object. /// @@ -74,4 +75,22 @@ class Caption { 'end: $end, ' 'text: $text)'; } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is Caption && + runtimeType == other.runtimeType && + number == other.number && + start == other.start && + end == other.end && + text == other.text; + + @override + int get hashCode => Object.hash( + number, + start, + end, + text, + ); } diff --git a/packages/video_player/video_player/lib/video_player.dart b/packages/video_player/video_player/lib/video_player.dart index 5720e2d9d13..03130a79caa 100644 --- a/packages/video_player/video_player/lib/video_player.dart +++ b/packages/video_player/video_player/lib/video_player.dart @@ -33,10 +33,11 @@ VideoPlayerPlatform get _videoPlayerPlatform { /// The duration, current position, buffering state, error state and settings /// of a [VideoPlayerController]. +@immutable class VideoPlayerValue { /// Constructs a video with the given values. Only [duration] is required. The /// rest will initialize with default values when unset. - VideoPlayerValue({ + const VideoPlayerValue({ required this.duration, this.size = Size.zero, this.position = Duration.zero, @@ -54,11 +55,11 @@ class VideoPlayerValue { }); /// Returns an instance for a video that hasn't been loaded. - VideoPlayerValue.uninitialized() + const VideoPlayerValue.uninitialized() : this(duration: Duration.zero, isInitialized: false); /// Returns an instance with the given [errorDescription]. - VideoPlayerValue.erroneous(String errorDescription) + const VideoPlayerValue.erroneous(String errorDescription) : this( duration: Duration.zero, isInitialized: false, @@ -195,6 +196,44 @@ class VideoPlayerValue { 'playbackSpeed: $playbackSpeed, ' 'errorDescription: $errorDescription)'; } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is VideoPlayerValue && + runtimeType == other.runtimeType && + duration == other.duration && + position == other.position && + caption == other.caption && + captionOffset == other.captionOffset && + listEquals(buffered, other.buffered) && + isPlaying == other.isPlaying && + isLooping == other.isLooping && + isBuffering == other.isBuffering && + volume == other.volume && + playbackSpeed == other.playbackSpeed && + errorDescription == other.errorDescription && + size == other.size && + rotationCorrection == other.rotationCorrection && + isInitialized == other.isInitialized; + + @override + int get hashCode => Object.hash( + duration, + position, + caption, + captionOffset, + buffered, + isPlaying, + isLooping, + isBuffering, + volume, + playbackSpeed, + errorDescription, + size, + rotationCorrection, + isInitialized, + ); } /// Controls a platform video player, and provides updates when the state is @@ -221,7 +260,7 @@ class VideoPlayerController extends ValueNotifier { dataSourceType = DataSourceType.asset, formatHint = null, httpHeaders = const {}, - super(VideoPlayerValue(duration: Duration.zero)); + super(const VideoPlayerValue(duration: Duration.zero)); /// Constructs a [VideoPlayerController] playing a video from obtained from /// the network. @@ -241,7 +280,7 @@ class VideoPlayerController extends ValueNotifier { }) : _closedCaptionFileFuture = closedCaptionFile, dataSourceType = DataSourceType.network, package = null, - super(VideoPlayerValue(duration: Duration.zero)); + super(const VideoPlayerValue(duration: Duration.zero)); /// Constructs a [VideoPlayerController] playing a video from a file. /// @@ -254,7 +293,7 @@ class VideoPlayerController extends ValueNotifier { package = null, formatHint = null, httpHeaders = const {}, - super(VideoPlayerValue(duration: Duration.zero)); + super(const VideoPlayerValue(duration: Duration.zero)); /// Constructs a [VideoPlayerController] playing a video from a contentUri. /// @@ -270,7 +309,7 @@ class VideoPlayerController extends ValueNotifier { package = null, formatHint = null, httpHeaders = const {}, - super(VideoPlayerValue(duration: Duration.zero)); + super(const VideoPlayerValue(duration: Duration.zero)); /// The URI to the video file. This will be in different formats depending on /// the [DataSourceType] of the original video. @@ -399,6 +438,9 @@ class VideoPlayerController extends ValueNotifier { case VideoEventType.bufferingEnd: value = value.copyWith(isBuffering: false); break; + case VideoEventType.isPlayingStateUpdate: + value = value.copyWith(isPlaying: event.isPlaying); + break; case VideoEventType.unknown: break; } diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index d75456ace46..8827a8c5a4a 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for displaying inline video with other Flutter widgets on Android, iOS, and web. repository: https://github.com/flutter/plugins/tree/main/packages/video_player/video_player issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 -version: 2.5.1 +version: 2.5.2 environment: sdk: ">=2.14.0 <3.0.0" @@ -31,3 +31,14 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_android: + path: ../video_player_android + video_player_avfoundation: + path: ../video_player_avfoundation + video_player_platform_interface: + path: ../video_player_platform_interface + video_player_web: + path: ../video_player_web \ No newline at end of file diff --git a/packages/video_player/video_player/test/video_player_test.dart b/packages/video_player/video_player/test/video_player_test.dart index 663fc9f8e89..f59c9feeca3 100644 --- a/packages/video_player/video_player/test/video_player_test.dart +++ b/packages/video_player/video_player/test/video_player_test.dart @@ -16,7 +16,7 @@ import 'package:video_player_platform_interface/video_player_platform_interface. class FakeController extends ValueNotifier implements VideoPlayerController { - FakeController() : super(VideoPlayerValue(duration: Duration.zero)); + FakeController() : super(const VideoPlayerValue(duration: Duration.zero)); FakeController.value(VideoPlayerValue value) : super(value); @@ -164,7 +164,8 @@ void main() { testWidgets('non-zero rotationCorrection value is used', (WidgetTester tester) async { final FakeController controller = FakeController.value( - VideoPlayerValue(duration: Duration.zero, rotationCorrection: 180)); + const VideoPlayerValue( + duration: Duration.zero, rotationCorrection: 180)); controller.textureId = 1; await tester.pumpWidget(VideoPlayer(controller)); final Transform actualRotationCorrection = @@ -184,7 +185,7 @@ void main() { testWidgets('no transform when rotationCorrection is zero', (WidgetTester tester) async { final FakeController controller = - FakeController.value(VideoPlayerValue(duration: Duration.zero)); + FakeController.value(const VideoPlayerValue(duration: Duration.zero)); controller.textureId = 1; await tester.pumpWidget(VideoPlayer(controller)); expect(find.byType(Transform), findsNothing); @@ -849,7 +850,7 @@ void main() { group('VideoPlayerValue', () { test('uninitialized()', () { - final VideoPlayerValue uninitialized = VideoPlayerValue.uninitialized(); + const VideoPlayerValue uninitialized = VideoPlayerValue.uninitialized(); expect(uninitialized.duration, equals(Duration.zero)); expect(uninitialized.position, equals(Duration.zero)); @@ -870,7 +871,7 @@ void main() { test('erroneous()', () { const String errorMessage = 'foo'; - final VideoPlayerValue error = VideoPlayerValue.erroneous(errorMessage); + const VideoPlayerValue error = VideoPlayerValue.erroneous(errorMessage); expect(error.duration, equals(Duration.zero)); expect(error.position, equals(Duration.zero)); @@ -940,26 +941,26 @@ void main() { group('copyWith()', () { test('exact copy', () { - final VideoPlayerValue original = VideoPlayerValue.uninitialized(); + const VideoPlayerValue original = VideoPlayerValue.uninitialized(); final VideoPlayerValue exactCopy = original.copyWith(); expect(exactCopy.toString(), original.toString()); }); test('errorDescription is not persisted when copy with null', () { - final VideoPlayerValue original = VideoPlayerValue.erroneous('error'); + const VideoPlayerValue original = VideoPlayerValue.erroneous('error'); final VideoPlayerValue copy = original.copyWith(errorDescription: null); expect(copy.errorDescription, null); }); test('errorDescription is changed when copy with another error', () { - final VideoPlayerValue original = VideoPlayerValue.erroneous('error'); + const VideoPlayerValue original = VideoPlayerValue.erroneous('error'); final VideoPlayerValue copy = original.copyWith(errorDescription: 'new error'); expect(copy.errorDescription, 'new error'); }); test('errorDescription is changed when copy with error', () { - final VideoPlayerValue original = VideoPlayerValue.uninitialized(); + const VideoPlayerValue original = VideoPlayerValue.uninitialized(); final VideoPlayerValue copy = original.copyWith(errorDescription: 'new error'); @@ -969,45 +970,45 @@ void main() { group('aspectRatio', () { test('640x480 -> 4:3', () { - final VideoPlayerValue value = VideoPlayerValue( + const VideoPlayerValue value = VideoPlayerValue( isInitialized: true, - size: const Size(640, 480), - duration: const Duration(seconds: 1), + size: Size(640, 480), + duration: Duration(seconds: 1), ); expect(value.aspectRatio, 4 / 3); }); test('no size -> 1.0', () { - final VideoPlayerValue value = VideoPlayerValue( + const VideoPlayerValue value = VideoPlayerValue( isInitialized: true, - duration: const Duration(seconds: 1), + duration: Duration(seconds: 1), ); expect(value.aspectRatio, 1.0); }); test('height = 0 -> 1.0', () { - final VideoPlayerValue value = VideoPlayerValue( + const VideoPlayerValue value = VideoPlayerValue( isInitialized: true, - size: const Size(640, 0), - duration: const Duration(seconds: 1), + size: Size(640, 0), + duration: Duration(seconds: 1), ); expect(value.aspectRatio, 1.0); }); test('width = 0 -> 1.0', () { - final VideoPlayerValue value = VideoPlayerValue( + const VideoPlayerValue value = VideoPlayerValue( isInitialized: true, - size: const Size(0, 480), - duration: const Duration(seconds: 1), + size: Size(0, 480), + duration: Duration(seconds: 1), ); expect(value.aspectRatio, 1.0); }); test('negative aspect ratio -> 1.0', () { - final VideoPlayerValue value = VideoPlayerValue( + const VideoPlayerValue value = VideoPlayerValue( isInitialized: true, - size: const Size(640, -480), - duration: const Duration(seconds: 1), + size: Size(640, -480), + duration: Duration(seconds: 1), ); expect(value.aspectRatio, 1.0); }); diff --git a/packages/video_player/video_player_android/AUTHORS b/packages/video_player/video_player_android/AUTHORS index 493a0b4ef9c..fc16c35c4c2 100644 --- a/packages/video_player/video_player_android/AUTHORS +++ b/packages/video_player/video_player_android/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_android/CHANGELOG.md b/packages/video_player/video_player_android/CHANGELOG.md index 56024c4ba23..85968f84fb3 100644 --- a/packages/video_player/video_player_android/CHANGELOG.md +++ b/packages/video_player/video_player_android/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 2.3.11 +* Synchronizes `VideoPlayerValue.isPlaying` with `ExoPlayer`. * Updates minimum Flutter version to 3.0. ## 2.3.10 diff --git a/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java b/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java index e130c995aa2..e1bf9ce3c90 100644 --- a/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java +++ b/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java @@ -232,6 +232,16 @@ public void onPlayerError(final PlaybackException error) { eventSink.error("VideoError", "Video player had error " + error, null); } } + + @Override + public void onIsPlayingChanged(boolean isPlaying) { + if (eventSink != null) { + Map event = new HashMap<>(); + event.put("event", "isPlayingStateUpdate"); + event.put("isPlaying", isPlaying); + eventSink.success(event); + } + } }); } 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 fb79a77fb2c..ad28b17a168 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 @@ -8,6 +8,7 @@ import 'dart:async'; import 'dart:io'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:video_player_platform_interface/video_player_platform_interface.dart'; @@ -24,10 +25,11 @@ VideoPlayerPlatform get _platform { /// The duration, current position, buffering state, error state and settings /// of a [MiniController]. +@immutable class VideoPlayerValue { /// Constructs a video with the given values. Only [duration] is required. The /// rest will initialize with default values when unset. - VideoPlayerValue({ + const VideoPlayerValue({ required this.duration, this.size = Size.zero, this.position = Duration.zero, @@ -40,11 +42,11 @@ class VideoPlayerValue { }); /// Returns an instance for a video that hasn't been loaded. - VideoPlayerValue.uninitialized() + const VideoPlayerValue.uninitialized() : this(duration: Duration.zero, isInitialized: false); /// Returns an instance with the given [errorDescription]. - VideoPlayerValue.erroneous(String errorDescription) + const VideoPlayerValue.erroneous(String errorDescription) : this( duration: Duration.zero, isInitialized: false, @@ -127,6 +129,34 @@ class VideoPlayerValue { errorDescription: errorDescription ?? this.errorDescription, ); } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is VideoPlayerValue && + runtimeType == other.runtimeType && + duration == other.duration && + position == other.position && + listEquals(buffered, other.buffered) && + isPlaying == other.isPlaying && + isBuffering == other.isBuffering && + playbackSpeed == other.playbackSpeed && + errorDescription == other.errorDescription && + size == other.size && + isInitialized == other.isInitialized; + + @override + int get hashCode => Object.hash( + duration, + position, + buffered, + isPlaying, + isBuffering, + playbackSpeed, + errorDescription, + size, + isInitialized, + ); } /// A very minimal version of `VideoPlayerController` for running the example @@ -139,21 +169,21 @@ class MiniController extends ValueNotifier { /// package and null otherwise. MiniController.asset(this.dataSource, {this.package}) : dataSourceType = DataSourceType.asset, - super(VideoPlayerValue(duration: Duration.zero)); + super(const VideoPlayerValue(duration: Duration.zero)); /// Constructs a [MiniController] playing a video from obtained from /// the network. MiniController.network(this.dataSource) : dataSourceType = DataSourceType.network, package = null, - super(VideoPlayerValue(duration: Duration.zero)); + super(const VideoPlayerValue(duration: Duration.zero)); /// Constructs a [MiniController] playing a video from obtained from a file. MiniController.file(File file) : dataSource = Uri.file(file.absolute.path).toString(), dataSourceType = DataSourceType.file, package = null, - super(VideoPlayerValue(duration: Duration.zero)); + super(const VideoPlayerValue(duration: Duration.zero)); /// The URI to the video file. This will be in different formats depending on /// the [DataSourceType] of the original video. @@ -243,6 +273,9 @@ class MiniController extends ValueNotifier { case VideoEventType.bufferingEnd: value = value.copyWith(isBuffering: false); break; + case VideoEventType.isPlayingStateUpdate: + value = value.copyWith(isPlaying: event.isPlaying); + break; case VideoEventType.unknown: break; } diff --git a/packages/video_player/video_player_android/example/pubspec.yaml b/packages/video_player/video_player_android/example/pubspec.yaml index 16ffe17e7ba..e5249523af2 100644 --- a/packages/video_player/video_player_android/example/pubspec.yaml +++ b/packages/video_player/video_player_android/example/pubspec.yaml @@ -33,3 +33,8 @@ flutter: assets: - assets/flutter-mark-square-64.png - assets/Butterfly-209.mp4 + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../../video_player_platform_interface \ No newline at end of file diff --git a/packages/video_player/video_player_android/lib/src/android_video_player.dart b/packages/video_player/video_player_android/lib/src/android_video_player.dart index cee6d7d38f6..18af9da30d5 100644 --- a/packages/video_player/video_player_android/lib/src/android_video_player.dart +++ b/packages/video_player/video_player_android/lib/src/android_video_player.dart @@ -147,6 +147,11 @@ class AndroidVideoPlayer extends VideoPlayerPlatform { return VideoEvent(eventType: VideoEventType.bufferingStart); case 'bufferingEnd': return VideoEvent(eventType: VideoEventType.bufferingEnd); + case 'isPlayingStateUpdate': + return VideoEvent( + eventType: VideoEventType.isPlayingStateUpdate, + isPlaying: map['isPlaying'] as bool, + ); default: return VideoEvent(eventType: VideoEventType.unknown); } diff --git a/packages/video_player/video_player_android/pubspec.yaml b/packages/video_player/video_player_android/pubspec.yaml index 3f46ec8a4d7..32f3f2f54e4 100644 --- a/packages/video_player/video_player_android/pubspec.yaml +++ b/packages/video_player/video_player_android/pubspec.yaml @@ -2,7 +2,7 @@ name: video_player_android description: Android implementation of the video_player plugin. repository: https://github.com/flutter/plugins/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.3.10 +version: 2.3.11 environment: sdk: ">=2.14.0 <3.0.0" @@ -26,3 +26,8 @@ dev_dependencies: flutter_test: sdk: flutter pigeon: ^2.0.1 + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../video_player_platform_interface \ No newline at end of file diff --git a/packages/video_player/video_player_android/test/android_video_player_test.dart b/packages/video_player/video_player_android/test/android_video_player_test.dart index 6aa24e5c180..06fa7d3e8f4 100644 --- a/packages/video_player/video_player_android/test/android_video_player_test.dart +++ b/packages/video_player/video_player_android/test/android_video_player_test.dart @@ -234,10 +234,11 @@ void main() { }); test('videoEventsFor', () async { + const String mockChannel = 'flutter.io/videoPlayer/videoEvents123'; _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .setMockMessageHandler( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, (ByteData? message) async { final MethodCall methodCall = const StandardMethodCodec().decodeMethodCall(message); @@ -245,7 +246,7 @@ void main() { await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .handlePlatformMessage( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'initialized', @@ -258,7 +259,7 @@ void main() { await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .handlePlatformMessage( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'initialized', @@ -272,7 +273,7 @@ void main() { await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .handlePlatformMessage( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'completed', @@ -282,7 +283,7 @@ void main() { await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .handlePlatformMessage( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'bufferingUpdate', @@ -296,7 +297,7 @@ void main() { await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .handlePlatformMessage( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'bufferingStart', @@ -306,13 +307,35 @@ void main() { await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .handlePlatformMessage( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'bufferingEnd', }), (ByteData? data) {}); + await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! + .defaultBinaryMessenger + .handlePlatformMessage( + mockChannel, + const StandardMethodCodec() + .encodeSuccessEnvelope({ + 'event': 'isPlayingStateUpdate', + 'isPlaying': true, + }), + (ByteData? data) {}); + + await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! + .defaultBinaryMessenger + .handlePlatformMessage( + mockChannel, + const StandardMethodCodec() + .encodeSuccessEnvelope({ + 'event': 'isPlayingStateUpdate', + 'isPlaying': false, + }), + (ByteData? data) {}); + return const StandardMethodCodec().encodeSuccessEnvelope(null); } else if (methodCall.method == 'cancel') { return const StandardMethodCodec().encodeSuccessEnvelope(null); @@ -351,6 +374,14 @@ void main() { ]), VideoEvent(eventType: VideoEventType.bufferingStart), VideoEvent(eventType: VideoEventType.bufferingEnd), + VideoEvent( + eventType: VideoEventType.isPlayingStateUpdate, + isPlaying: true, + ), + VideoEvent( + eventType: VideoEventType.isPlayingStateUpdate, + isPlaying: false, + ), ])); }); }); diff --git a/packages/video_player/video_player_avfoundation/AUTHORS b/packages/video_player/video_player_avfoundation/AUTHORS index 493a0b4ef9c..fc16c35c4c2 100644 --- a/packages/video_player/video_player_avfoundation/AUTHORS +++ b/packages/video_player/video_player_avfoundation/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_avfoundation/CHANGELOG.md b/packages/video_player/video_player_avfoundation/CHANGELOG.md index b8564c0a223..9ba92a1cf89 100644 --- a/packages/video_player/video_player_avfoundation/CHANGELOG.md +++ b/packages/video_player/video_player_avfoundation/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 2.3.9 +* Synchronizes `VideoPlayerValue.isPlaying` with `AVPlayer`. * Updates minimum Flutter version to 3.0. ## 2.3.8 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 fb79a77fb2c..ad28b17a168 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 @@ -8,6 +8,7 @@ import 'dart:async'; import 'dart:io'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:video_player_platform_interface/video_player_platform_interface.dart'; @@ -24,10 +25,11 @@ VideoPlayerPlatform get _platform { /// The duration, current position, buffering state, error state and settings /// of a [MiniController]. +@immutable class VideoPlayerValue { /// Constructs a video with the given values. Only [duration] is required. The /// rest will initialize with default values when unset. - VideoPlayerValue({ + const VideoPlayerValue({ required this.duration, this.size = Size.zero, this.position = Duration.zero, @@ -40,11 +42,11 @@ class VideoPlayerValue { }); /// Returns an instance for a video that hasn't been loaded. - VideoPlayerValue.uninitialized() + const VideoPlayerValue.uninitialized() : this(duration: Duration.zero, isInitialized: false); /// Returns an instance with the given [errorDescription]. - VideoPlayerValue.erroneous(String errorDescription) + const VideoPlayerValue.erroneous(String errorDescription) : this( duration: Duration.zero, isInitialized: false, @@ -127,6 +129,34 @@ class VideoPlayerValue { errorDescription: errorDescription ?? this.errorDescription, ); } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is VideoPlayerValue && + runtimeType == other.runtimeType && + duration == other.duration && + position == other.position && + listEquals(buffered, other.buffered) && + isPlaying == other.isPlaying && + isBuffering == other.isBuffering && + playbackSpeed == other.playbackSpeed && + errorDescription == other.errorDescription && + size == other.size && + isInitialized == other.isInitialized; + + @override + int get hashCode => Object.hash( + duration, + position, + buffered, + isPlaying, + isBuffering, + playbackSpeed, + errorDescription, + size, + isInitialized, + ); } /// A very minimal version of `VideoPlayerController` for running the example @@ -139,21 +169,21 @@ class MiniController extends ValueNotifier { /// package and null otherwise. MiniController.asset(this.dataSource, {this.package}) : dataSourceType = DataSourceType.asset, - super(VideoPlayerValue(duration: Duration.zero)); + super(const VideoPlayerValue(duration: Duration.zero)); /// Constructs a [MiniController] playing a video from obtained from /// the network. MiniController.network(this.dataSource) : dataSourceType = DataSourceType.network, package = null, - super(VideoPlayerValue(duration: Duration.zero)); + super(const VideoPlayerValue(duration: Duration.zero)); /// Constructs a [MiniController] playing a video from obtained from a file. MiniController.file(File file) : dataSource = Uri.file(file.absolute.path).toString(), dataSourceType = DataSourceType.file, package = null, - super(VideoPlayerValue(duration: Duration.zero)); + super(const VideoPlayerValue(duration: Duration.zero)); /// The URI to the video file. This will be in different formats depending on /// the [DataSourceType] of the original video. @@ -243,6 +273,9 @@ class MiniController extends ValueNotifier { case VideoEventType.bufferingEnd: value = value.copyWith(isBuffering: false); break; + case VideoEventType.isPlayingStateUpdate: + value = value.copyWith(isPlaying: event.isPlaying); + break; case VideoEventType.unknown: break; } diff --git a/packages/video_player/video_player_avfoundation/example/pubspec.yaml b/packages/video_player/video_player_avfoundation/example/pubspec.yaml index 422fb91e35e..5d43e02e6a0 100644 --- a/packages/video_player/video_player_avfoundation/example/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/example/pubspec.yaml @@ -33,3 +33,8 @@ flutter: assets: - assets/flutter-mark-square-64.png - assets/Butterfly-209.mp4 + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../../video_player_platform_interface \ No newline at end of file diff --git a/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m b/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m index 3b066769621..a440e77663f 100644 --- a/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m +++ b/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m @@ -62,6 +62,7 @@ - (instancetype)initWithURL:(NSURL *)url static void *playbackLikelyToKeepUpContext = &playbackLikelyToKeepUpContext; static void *playbackBufferEmptyContext = &playbackBufferEmptyContext; static void *playbackBufferFullContext = &playbackBufferFullContext; +static void *rateContext = &rateContext; @implementation FLTVideoPlayer - (instancetype)initWithAsset:(NSString *)asset frameUpdater:(FLTFrameUpdater *)frameUpdater { @@ -69,7 +70,7 @@ - (instancetype)initWithAsset:(NSString *)asset frameUpdater:(FLTFrameUpdater *) return [self initWithURL:[NSURL fileURLWithPath:path] frameUpdater:frameUpdater httpHeaders:@{}]; } -- (void)addObservers:(AVPlayerItem *)item { +- (void)addObserversForItem:(AVPlayerItem *)item player:(AVPlayer *)player { [item addObserver:self forKeyPath:@"loadedTimeRanges" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew @@ -99,6 +100,13 @@ - (void)addObservers:(AVPlayerItem *)item { options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:playbackBufferFullContext]; + // Add observer to AVPlayer instead of AVPlayerItem since the AVPlayerItem does not have a "rate" + // property + [player addObserver:self + forKeyPath:@"rate" + options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew + context:rateContext]; + // Add an observer that will respond to itemDidPlayToEndTime [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidPlayToEndTime:) @@ -252,7 +260,7 @@ - (instancetype)initWithPlayerItem:(AVPlayerItem *)item [self createVideoOutputAndDisplayLink:frameUpdater]; - [self addObservers:item]; + [self addObserversForItem:item player:_player]; [asset loadValuesAsynchronouslyForKeys:@[ @"tracks" ] completionHandler:assetCompletionHandler]; @@ -317,6 +325,14 @@ - (void)observeValueForKeyPath:(NSString *)path if (_eventSink != nil) { _eventSink(@{@"event" : @"bufferingEnd"}); } + } else if (context == rateContext) { + // Important: Make sure to cast the object to AVPlayer when observing the rate property, + // as it is not available in AVPlayerItem. + AVPlayer *player = (AVPlayer *)object; + if (_eventSink != nil) { + _eventSink( + @{@"event" : @"isPlayingStateUpdate", @"isPlaying" : player.rate > 0 ? @YES : @NO}); + } } } diff --git a/packages/video_player/video_player_avfoundation/lib/src/avfoundation_video_player.dart b/packages/video_player/video_player_avfoundation/lib/src/avfoundation_video_player.dart index b5ebedda41e..868c5986f35 100644 --- a/packages/video_player/video_player_avfoundation/lib/src/avfoundation_video_player.dart +++ b/packages/video_player/video_player_avfoundation/lib/src/avfoundation_video_player.dart @@ -146,6 +146,11 @@ class AVFoundationVideoPlayer extends VideoPlayerPlatform { return VideoEvent(eventType: VideoEventType.bufferingStart); case 'bufferingEnd': return VideoEvent(eventType: VideoEventType.bufferingEnd); + case 'isPlayingStateUpdate': + return VideoEvent( + eventType: VideoEventType.isPlayingStateUpdate, + isPlaying: map['isPlaying'] as bool, + ); default: return VideoEvent(eventType: VideoEventType.unknown); } diff --git a/packages/video_player/video_player_avfoundation/pubspec.yaml b/packages/video_player/video_player_avfoundation/pubspec.yaml index a5204137af2..6564fd1bdeb 100644 --- a/packages/video_player/video_player_avfoundation/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/pubspec.yaml @@ -2,7 +2,7 @@ name: video_player_avfoundation description: iOS implementation of the video_player plugin. repository: https://github.com/flutter/plugins/tree/main/packages/video_player/video_player_avfoundation issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 -version: 2.3.8 +version: 2.3.9 environment: sdk: ">=2.14.0 <3.0.0" @@ -25,3 +25,8 @@ dev_dependencies: flutter_test: sdk: flutter pigeon: ^2.0.1 + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../video_player_platform_interface \ No newline at end of file diff --git a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart index c01373f0542..1d10eed2286 100644 --- a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart +++ b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart @@ -234,10 +234,11 @@ void main() { }); test('videoEventsFor', () async { + const String mockChannel = 'flutter.io/videoPlayer/videoEvents123'; _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .setMockMessageHandler( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, (ByteData? message) async { final MethodCall methodCall = const StandardMethodCodec().decodeMethodCall(message); @@ -245,7 +246,7 @@ void main() { await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .handlePlatformMessage( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'initialized', @@ -258,7 +259,7 @@ void main() { await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .handlePlatformMessage( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'completed', @@ -268,7 +269,7 @@ void main() { await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .handlePlatformMessage( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'bufferingUpdate', @@ -282,7 +283,7 @@ void main() { await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .handlePlatformMessage( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'bufferingStart', @@ -292,13 +293,35 @@ void main() { await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! .defaultBinaryMessenger .handlePlatformMessage( - 'flutter.io/videoPlayer/videoEvents123', + mockChannel, const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'bufferingEnd', }), (ByteData? data) {}); + await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! + .defaultBinaryMessenger + .handlePlatformMessage( + mockChannel, + const StandardMethodCodec() + .encodeSuccessEnvelope({ + 'event': 'isPlayingStateUpdate', + 'isPlaying': true, + }), + (ByteData? data) {}); + + await _ambiguate(TestDefaultBinaryMessengerBinding.instance)! + .defaultBinaryMessenger + .handlePlatformMessage( + mockChannel, + const StandardMethodCodec() + .encodeSuccessEnvelope({ + 'event': 'isPlayingStateUpdate', + 'isPlaying': false, + }), + (ByteData? data) {}); + return const StandardMethodCodec().encodeSuccessEnvelope(null); } else if (methodCall.method == 'cancel') { return const StandardMethodCodec().encodeSuccessEnvelope(null); @@ -330,6 +353,14 @@ void main() { ]), VideoEvent(eventType: VideoEventType.bufferingStart), VideoEvent(eventType: VideoEventType.bufferingEnd), + VideoEvent( + eventType: VideoEventType.isPlayingStateUpdate, + isPlaying: true, + ), + VideoEvent( + eventType: VideoEventType.isPlayingStateUpdate, + isPlaying: false, + ), ])); }); }); 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 e1acbf57802..9fc20b11287 100644 --- a/packages/video_player/video_player_platform_interface/CHANGELOG.md +++ b/packages/video_player/video_player_platform_interface/CHANGELOG.md @@ -1,5 +1,7 @@ -## NEXT +## 6.0.2 +* Add the `VideoEventType.isPlayingStateUpdate` event to track changes in play / pause state with +the underlying video player. * Updates minimum Flutter version to 3.0. ## 6.0.1 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 8c6a8f400bb..6400218e8df 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/plugins/tree/main/packages/video_player/v 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.1 +version: 6.0.2 environment: sdk: ">=2.12.0 <3.0.0" diff --git a/packages/video_player/video_player_web/AUTHORS b/packages/video_player/video_player_web/AUTHORS index 493a0b4ef9c..fc16c35c4c2 100644 --- a/packages/video_player/video_player_web/AUTHORS +++ b/packages/video_player/video_player_web/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_web/CHANGELOG.md b/packages/video_player/video_player_web/CHANGELOG.md index 42355439ce1..5a65d2f773c 100644 --- a/packages/video_player/video_player_web/CHANGELOG.md +++ b/packages/video_player/video_player_web/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 2.0.14 +* Synchronizes `VideoPlayerValue.isPlaying` with `VideoElement`. * Updates minimum Flutter version to 3.0. ## 2.0.13 diff --git a/packages/video_player/video_player_web/example/integration_test/video_player_web_test.dart b/packages/video_player/video_player_web/example/integration_test/video_player_web_test.dart index 5053ea6e5b0..1d70104aca9 100644 --- a/packages/video_player/video_player_web/example/integration_test/video_player_web_test.dart +++ b/packages/video_player/video_player_web/example/integration_test/video_player_web_test.dart @@ -169,7 +169,9 @@ void main() { expect(VideoPlayerPlatform.instance.setMixWithOthers(false), completes); }); - testWidgets('video playback lifecycle', (WidgetTester tester) async { + testWidgets( + 'double call to play will emit a single isPlayingStateUpdate event', + (WidgetTester tester) async { final int videoPlayerId = await textureId; final Stream eventStream = VideoPlayerPlatform.instance.videoEventsFor(videoPlayerId); @@ -181,26 +183,60 @@ void main() { }, ).toList(); + await VideoPlayerPlatform.instance.setVolume(videoPlayerId, 0); + await VideoPlayerPlatform.instance.play(videoPlayerId); + await VideoPlayerPlatform.instance.play(videoPlayerId); + + // Let the video play, until we stop seeing events for two seconds + final List events = await stream; + + await VideoPlayerPlatform.instance.pause(videoPlayerId); + + expect( + events.where((VideoEvent e) => + e.eventType == VideoEventType.isPlayingStateUpdate), + equals([ + VideoEvent( + eventType: VideoEventType.isPlayingStateUpdate, + isPlaying: true, + ) + ])); + }); + + testWidgets('video playback lifecycle', (WidgetTester tester) async { + final int videoPlayerId = await textureId; + final Stream eventStream = + VideoPlayerPlatform.instance.videoEventsFor(videoPlayerId); + + final Future> stream = eventStream.timeout( + const Duration(seconds: 2), + onTimeout: (EventSink sink) { + sink.close(); + }, + ).toList(); + await VideoPlayerPlatform.instance.setVolume(videoPlayerId, 0); await VideoPlayerPlatform.instance.play(videoPlayerId); - // Let the video play, until we stop seeing events for a second + // Let the video play, until we stop seeing events for two seconds final List events = await stream; await VideoPlayerPlatform.instance.pause(videoPlayerId); // The expected list of event types should look like this: - // 1. bufferingStart, - // 2. bufferingUpdate (videoElement.onWaiting), - // 3. initialized (videoElement.onCanPlay), - // 4. bufferingEnd (videoElement.onCanPlayThrough), + // 1. isPlayingStateUpdate (videoElement.onPlaying) + // 2. bufferingStart, + // 3. bufferingUpdate (videoElement.onWaiting), + // 4. initialized (videoElement.onCanPlay), + // 5. bufferingEnd (videoElement.onCanPlayThrough), expect( events.map((VideoEvent e) => e.eventType), equals([ + VideoEventType.isPlayingStateUpdate, VideoEventType.bufferingStart, VideoEventType.bufferingUpdate, VideoEventType.initialized, - VideoEventType.bufferingEnd + VideoEventType.bufferingEnd, ])); }); }); diff --git a/packages/video_player/video_player_web/example/pubspec.yaml b/packages/video_player/video_player_web/example/pubspec.yaml index c4de1ce54c1..6a62152feba 100644 --- a/packages/video_player/video_player_web/example/pubspec.yaml +++ b/packages/video_player/video_player_web/example/pubspec.yaml @@ -20,3 +20,8 @@ dev_dependencies: sdk: flutter integration_test: sdk: flutter + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../../video_player_platform_interface \ No newline at end of file diff --git a/packages/video_player/video_player_web/lib/src/video_player.dart b/packages/video_player/video_player_web/lib/src/video_player.dart index 02ead1fdf93..bc0021dee34 100644 --- a/packages/video_player/video_player_web/lib/src/video_player.dart +++ b/packages/video_player/video_player_web/lib/src/video_player.dart @@ -102,6 +102,20 @@ class VideoPlayer { )); }); + _videoElement.onPlay.listen((dynamic _) { + _eventController.add(VideoEvent( + eventType: VideoEventType.isPlayingStateUpdate, + isPlaying: true, + )); + }); + + _videoElement.onPause.listen((dynamic _) { + _eventController.add(VideoEvent( + eventType: VideoEventType.isPlayingStateUpdate, + isPlaying: false, + )); + }); + _videoElement.onEnded.listen((dynamic _) { setBuffering(false); _eventController.add(VideoEvent(eventType: VideoEventType.completed)); diff --git a/packages/video_player/video_player_web/pubspec.yaml b/packages/video_player/video_player_web/pubspec.yaml index 5e603034dd2..2b2d5f93e86 100644 --- a/packages/video_player/video_player_web/pubspec.yaml +++ b/packages/video_player/video_player_web/pubspec.yaml @@ -2,7 +2,7 @@ name: video_player_web description: Web platform implementation of video_player. repository: https://github.com/flutter/plugins/tree/main/packages/video_player/video_player_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 -version: 2.0.13 +version: 2.0.14 environment: sdk: ">=2.12.0 <3.0.0" @@ -26,3 +26,8 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../video_player_platform_interface \ No newline at end of file From 6149904face3a2228ed3888566098efcf2cb89fa Mon Sep 17 00:00:00 2001 From: maRci002 Date: Wed, 22 Feb 2023 20:25:13 +0100 Subject: [PATCH 02/15] Remove dependecy_overrides from video_player package --- .../video_player/video_player/example/pubspec.yaml | 5 ----- packages/video_player/video_player/pubspec.yaml | 11 ----------- 2 files changed, 16 deletions(-) diff --git a/packages/video_player/video_player/example/pubspec.yaml b/packages/video_player/video_player/example/pubspec.yaml index 2e100859c1d..0b30e9fb01e 100644 --- a/packages/video_player/video_player/example/pubspec.yaml +++ b/packages/video_player/video_player/example/pubspec.yaml @@ -37,8 +37,3 @@ flutter: - assets/bumble_bee_captions.srt - assets/bumble_bee_captions.vtt - assets/Audio.mp3 - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player_platform_interface: - path: ../../video_player_platform_interface \ No newline at end of file diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index 76cbcce607b..6519b109e27 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -31,14 +31,3 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player_android: - path: ../video_player_android - video_player_avfoundation: - path: ../video_player_avfoundation - video_player_platform_interface: - path: ../video_player_platform_interface - video_player_web: - path: ../video_player_web \ No newline at end of file From bcfedbb181e7a658a8788542a164a09932845d1d Mon Sep 17 00:00:00 2001 From: maRci002 Date: Thu, 23 Feb 2023 08:51:25 +0100 Subject: [PATCH 03/15] remove dependency_overrides --- .../video_player/video_player_android/example/pubspec.yaml | 5 ----- .../video_player_avfoundation/example/pubspec.yaml | 5 ----- 2 files changed, 10 deletions(-) diff --git a/packages/video_player/video_player_android/example/pubspec.yaml b/packages/video_player/video_player_android/example/pubspec.yaml index e5249523af2..16ffe17e7ba 100644 --- a/packages/video_player/video_player_android/example/pubspec.yaml +++ b/packages/video_player/video_player_android/example/pubspec.yaml @@ -33,8 +33,3 @@ flutter: assets: - assets/flutter-mark-square-64.png - assets/Butterfly-209.mp4 - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player_platform_interface: - path: ../../video_player_platform_interface \ No newline at end of file diff --git a/packages/video_player/video_player_avfoundation/example/pubspec.yaml b/packages/video_player/video_player_avfoundation/example/pubspec.yaml index 5d43e02e6a0..422fb91e35e 100644 --- a/packages/video_player/video_player_avfoundation/example/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/example/pubspec.yaml @@ -33,8 +33,3 @@ flutter: assets: - assets/flutter-mark-square-64.png - assets/Butterfly-209.mp4 - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player_platform_interface: - path: ../../video_player_platform_interface \ No newline at end of file From 5d512f9dc4649cd6188632a17c75fb2699c4d9cb Mon Sep 17 00:00:00 2001 From: maRci002 Date: Fri, 24 Feb 2023 09:44:06 +0100 Subject: [PATCH 04/15] increase stream timeout to reflect comment in test --- .../example/integration_test/video_player_web_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/video_player/video_player_web/example/integration_test/video_player_web_test.dart b/packages/video_player/video_player_web/example/integration_test/video_player_web_test.dart index 1d70104aca9..7d742239309 100644 --- a/packages/video_player/video_player_web/example/integration_test/video_player_web_test.dart +++ b/packages/video_player/video_player_web/example/integration_test/video_player_web_test.dart @@ -177,7 +177,7 @@ void main() { VideoPlayerPlatform.instance.videoEventsFor(videoPlayerId); final Future> stream = eventStream.timeout( - const Duration(seconds: 1), + const Duration(seconds: 2), onTimeout: (EventSink sink) { sink.close(); }, From 1d1e42dad4e27450f79f8ea0339a7bebc8d711b8 Mon Sep 17 00:00:00 2001 From: maRci002 Date: Tue, 28 Feb 2023 01:21:47 +0100 Subject: [PATCH 05/15] add android test --- .../plugins/videoplayer/VideoPlayerTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java b/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java index 194f7905b63..7479ae56891 100644 --- a/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java +++ b/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java @@ -5,7 +5,10 @@ package io.flutter.plugins.videoplayer; import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -14,12 +17,14 @@ import io.flutter.plugin.common.EventChannel; import io.flutter.view.TextureRegistry; import java.util.HashMap; +import java.util.Map; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.MockitoAnnotations; +import org.mockito.stubbing.Answer; import org.robolectric.RobolectricTestRunner; @RunWith(RobolectricTestRunner.class) @@ -154,4 +159,43 @@ public void sendInitializedSendsExpectedEvent_180RotationDegrees() { assertEquals(event.get("height"), 200); assertEquals(event.get("rotationCorrection"), 180); } + + @Test + public void onIsPlayingChangedSendsExpectedEvent() { + VideoPlayer videoPlayer = + new VideoPlayer( + fakeExoPlayer, + fakeEventChannel, + fakeSurfaceTextureEntry, + fakeVideoPlayerOptions, + fakeEventSink); + + doAnswer( + (Answer) + invocation -> { + Map event = new HashMap<>(); + event.put("event", "isPlayingStateUpdate"); + event.put("isPlaying", (Boolean) invocation.getArguments()[0]); + fakeEventSink.success(event); + return null; + }) + .when(fakeExoPlayer) + .setPlayWhenReady(anyBoolean()); + + videoPlayer.play(); + + verify(fakeEventSink).success(eventCaptor.capture()); + HashMap event1 = eventCaptor.getValue(); + + assertEquals(event1.get("event"), "isPlayingStateUpdate"); + assertEquals(event1.get("isPlaying"), true); + + videoPlayer.pause(); + + verify(fakeEventSink, times(2)).success(eventCaptor.capture()); + HashMap event2 = eventCaptor.getValue(); + + assertEquals(event2.get("event"), "isPlayingStateUpdate"); + assertEquals(event2.get("isPlaying"), false); + } } From d9480d89c874fa6d0a5e65de7977793bd4208f0c Mon Sep 17 00:00:00 2001 From: maRci002 Date: Thu, 2 Mar 2023 22:39:18 +0100 Subject: [PATCH 06/15] readd dependency_overrides to pass tests --- .../video_player/video_player/example/pubspec.yaml | 5 +++++ packages/video_player/video_player/pubspec.yaml | 11 +++++++++++ .../video_player_android/example/pubspec.yaml | 5 +++++ .../video_player/video_player_android/pubspec.yaml | 5 +++++ .../video_player_avfoundation/example/pubspec.yaml | 5 +++++ .../video_player_avfoundation/pubspec.yaml | 5 +++++ .../video_player_web/example/pubspec.yaml | 5 +++++ packages/video_player/video_player_web/pubspec.yaml | 5 +++++ 8 files changed, 46 insertions(+) diff --git a/packages/video_player/video_player/example/pubspec.yaml b/packages/video_player/video_player/example/pubspec.yaml index 0b30e9fb01e..b7ba80d89fc 100644 --- a/packages/video_player/video_player/example/pubspec.yaml +++ b/packages/video_player/video_player/example/pubspec.yaml @@ -37,3 +37,8 @@ flutter: - assets/bumble_bee_captions.srt - assets/bumble_bee_captions.vtt - assets/Audio.mp3 + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../../video_player_platform_interface diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index 3943d4aafa4..a9c5ea277ff 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -31,3 +31,14 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_android: + path: ../video_player_android + video_player_avfoundation: + path: ../video_player_avfoundation + video_player_platform_interface: + path: ../video_player_platform_interface + video_player_web: + path: ../video_player_web diff --git a/packages/video_player/video_player_android/example/pubspec.yaml b/packages/video_player/video_player_android/example/pubspec.yaml index 16ffe17e7ba..dfc3be4ef27 100644 --- a/packages/video_player/video_player_android/example/pubspec.yaml +++ b/packages/video_player/video_player_android/example/pubspec.yaml @@ -33,3 +33,8 @@ flutter: assets: - assets/flutter-mark-square-64.png - assets/Butterfly-209.mp4 + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../../video_player_platform_interface diff --git a/packages/video_player/video_player_android/pubspec.yaml b/packages/video_player/video_player_android/pubspec.yaml index 7bf68270613..d9a4db95421 100644 --- a/packages/video_player/video_player_android/pubspec.yaml +++ b/packages/video_player/video_player_android/pubspec.yaml @@ -26,3 +26,8 @@ dev_dependencies: flutter_test: sdk: flutter pigeon: ^2.0.1 + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../video_player_platform_interface diff --git a/packages/video_player/video_player_avfoundation/example/pubspec.yaml b/packages/video_player/video_player_avfoundation/example/pubspec.yaml index 422fb91e35e..5dea0200f2a 100644 --- a/packages/video_player/video_player_avfoundation/example/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/example/pubspec.yaml @@ -33,3 +33,8 @@ flutter: assets: - assets/flutter-mark-square-64.png - assets/Butterfly-209.mp4 + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../../video_player_platform_interface diff --git a/packages/video_player/video_player_avfoundation/pubspec.yaml b/packages/video_player/video_player_avfoundation/pubspec.yaml index 7618a8e76f8..adcd67e0343 100644 --- a/packages/video_player/video_player_avfoundation/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/pubspec.yaml @@ -25,3 +25,8 @@ dev_dependencies: flutter_test: sdk: flutter pigeon: ^2.0.1 + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../video_player_platform_interface diff --git a/packages/video_player/video_player_web/example/pubspec.yaml b/packages/video_player/video_player_web/example/pubspec.yaml index c4de1ce54c1..85503cd24ed 100644 --- a/packages/video_player/video_player_web/example/pubspec.yaml +++ b/packages/video_player/video_player_web/example/pubspec.yaml @@ -20,3 +20,8 @@ dev_dependencies: sdk: flutter integration_test: sdk: flutter + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../../video_player_platform_interface diff --git a/packages/video_player/video_player_web/pubspec.yaml b/packages/video_player/video_player_web/pubspec.yaml index 29f97670070..b03cdc18a3a 100644 --- a/packages/video_player/video_player_web/pubspec.yaml +++ b/packages/video_player/video_player_web/pubspec.yaml @@ -26,3 +26,8 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player_platform_interface: + path: ../video_player_platform_interface From deec84174c7657671dc67d82550e20803fc3ea99 Mon Sep 17 00:00:00 2001 From: maRci002 Date: Thu, 2 Mar 2023 23:18:04 +0100 Subject: [PATCH 07/15] update android changelog --- packages/video_player/video_player_android/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/video_player/video_player_android/CHANGELOG.md b/packages/video_player/video_player_android/CHANGELOG.md index 8f404422a55..69b4557b816 100644 --- a/packages/video_player/video_player_android/CHANGELOG.md +++ b/packages/video_player/video_player_android/CHANGELOG.md @@ -1,6 +1,9 @@ ## NEXT * Updates compileSdkVersion to 33. + +## 2.3.12 + * Synchronizes `VideoPlayerValue.isPlaying` with `ExoPlayer`. ## 2.3.11 From 14ff92c08f25528e431700265f74eb63ef505ea9 Mon Sep 17 00:00:00 2001 From: maRci002 Date: Thu, 2 Mar 2023 23:43:31 +0100 Subject: [PATCH 08/15] update changelog --- packages/video_player/video_player_android/CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/video_player/video_player_android/CHANGELOG.md b/packages/video_player/video_player_android/CHANGELOG.md index 69b4557b816..7e386eb7162 100644 --- a/packages/video_player/video_player_android/CHANGELOG.md +++ b/packages/video_player/video_player_android/CHANGELOG.md @@ -1,9 +1,6 @@ -## NEXT - -* Updates compileSdkVersion to 33. - ## 2.3.12 +* Updates compileSdkVersion to 33. * Synchronizes `VideoPlayerValue.isPlaying` with `ExoPlayer`. ## 2.3.11 From a7eabedadff047ddeeb1595e8186a0222d52882e Mon Sep 17 00:00:00 2001 From: maRci002 Date: Fri, 3 Mar 2023 14:55:49 +0100 Subject: [PATCH 09/15] override video_player / video_player_platform_interface dependency for image picker examples --- packages/camera/camera/example/pubspec.yaml | 8 ++++++++ packages/camera/camera/pubspec.yaml | 8 ++++++++ packages/camera/camera_android/example/pubspec.yaml | 8 ++++++++ .../camera/camera_android_camerax/example/pubspec.yaml | 8 ++++++++ packages/camera/camera_avfoundation/example/pubspec.yaml | 8 ++++++++ packages/image_picker/image_picker/example/pubspec.yaml | 8 ++++++++ .../image_picker_android/example/pubspec.yaml | 8 ++++++++ .../image_picker/image_picker_ios/example/pubspec.yaml | 8 ++++++++ .../image_picker_windows/example/pubspec.yaml | 8 ++++++++ 9 files changed, 72 insertions(+) diff --git a/packages/camera/camera/example/pubspec.yaml b/packages/camera/camera/example/pubspec.yaml index e63024076fe..5a78af51237 100644 --- a/packages/camera/camera/example/pubspec.yaml +++ b/packages/camera/camera/example/pubspec.yaml @@ -30,3 +30,11 @@ dev_dependencies: flutter: uses-material-design: true + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player: + path: ../../../video_player/video_player + video_player_platform_interface: + path: ../../../video_player/video_player_platform_interface diff --git a/packages/camera/camera/pubspec.yaml b/packages/camera/camera/pubspec.yaml index 74ef53c3878..c613685d2b8 100644 --- a/packages/camera/camera/pubspec.yaml +++ b/packages/camera/camera/pubspec.yaml @@ -38,3 +38,11 @@ dev_dependencies: mockito: ^5.0.0 plugin_platform_interface: ^2.0.0 video_player: ^2.0.0 + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player: + path: ../../video_player/video_player + video_player_platform_interface: + path: ../../video_player/video_player_platform_interface diff --git a/packages/camera/camera_android/example/pubspec.yaml b/packages/camera/camera_android/example/pubspec.yaml index e23e31a886d..900b5535768 100644 --- a/packages/camera/camera_android/example/pubspec.yaml +++ b/packages/camera/camera_android/example/pubspec.yaml @@ -32,3 +32,11 @@ dev_dependencies: flutter: uses-material-design: true + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player: + path: ../../../video_player/video_player + video_player_platform_interface: + path: ../../../video_player/video_player_platform_interface diff --git a/packages/camera/camera_android_camerax/example/pubspec.yaml b/packages/camera/camera_android_camerax/example/pubspec.yaml index 49a29b8517d..f995f2357ce 100644 --- a/packages/camera/camera_android_camerax/example/pubspec.yaml +++ b/packages/camera/camera_android_camerax/example/pubspec.yaml @@ -27,3 +27,11 @@ dev_dependencies: flutter: uses-material-design: true + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player: + path: ../../../video_player/video_player + video_player_platform_interface: + path: ../../../video_player/video_player_platform_interface diff --git a/packages/camera/camera_avfoundation/example/pubspec.yaml b/packages/camera/camera_avfoundation/example/pubspec.yaml index 7c85ba80719..8dfc3f6d165 100644 --- a/packages/camera/camera_avfoundation/example/pubspec.yaml +++ b/packages/camera/camera_avfoundation/example/pubspec.yaml @@ -32,3 +32,11 @@ dev_dependencies: flutter: uses-material-design: true + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player: + path: ../../../video_player/video_player + video_player_platform_interface: + path: ../../../video_player/video_player_platform_interface diff --git a/packages/image_picker/image_picker/example/pubspec.yaml b/packages/image_picker/image_picker/example/pubspec.yaml index 3d97877498d..7ef52bde711 100755 --- a/packages/image_picker/image_picker/example/pubspec.yaml +++ b/packages/image_picker/image_picker/example/pubspec.yaml @@ -30,3 +30,11 @@ dev_dependencies: flutter: uses-material-design: true + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player: + path: ../../../video_player/video_player + video_player_platform_interface: + path: ../../../video_player/video_player_platform_interface diff --git a/packages/image_picker/image_picker_android/example/pubspec.yaml b/packages/image_picker/image_picker_android/example/pubspec.yaml index bfeac3de14d..3652e0aff02 100755 --- a/packages/image_picker/image_picker_android/example/pubspec.yaml +++ b/packages/image_picker/image_picker_android/example/pubspec.yaml @@ -31,3 +31,11 @@ dev_dependencies: flutter: uses-material-design: true + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player: + path: ../../../video_player/video_player + video_player_platform_interface: + path: ../../../video_player/video_player_platform_interface diff --git a/packages/image_picker/image_picker_ios/example/pubspec.yaml b/packages/image_picker/image_picker_ios/example/pubspec.yaml index bebe9bb0464..1d49f81c31e 100755 --- a/packages/image_picker/image_picker_ios/example/pubspec.yaml +++ b/packages/image_picker/image_picker_ios/example/pubspec.yaml @@ -29,3 +29,11 @@ dev_dependencies: flutter: uses-material-design: true + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player: + path: ../../../video_player/video_player + video_player_platform_interface: + path: ../../../video_player/video_player_platform_interface diff --git a/packages/image_picker/image_picker_windows/example/pubspec.yaml b/packages/image_picker/image_picker_windows/example/pubspec.yaml index bdbd182d3fc..0141b12218f 100644 --- a/packages/image_picker/image_picker_windows/example/pubspec.yaml +++ b/packages/image_picker/image_picker_windows/example/pubspec.yaml @@ -26,3 +26,11 @@ dev_dependencies: flutter: uses-material-design: true + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + video_player: + path: ../../../video_player/video_player + video_player_platform_interface: + path: ../../../video_player/video_player_platform_interface From 31c19780fd3070063ffd527a35fdd9c987434fda Mon Sep 17 00:00:00 2001 From: maRci002 Date: Fri, 3 Mar 2023 19:16:41 +0100 Subject: [PATCH 10/15] apply requested changes --- .../video_player/test/video_player_test.dart | 24 +++++++++++++++++++ .../CHANGELOG.md | 2 +- .../lib/video_player_platform_interface.dart | 12 ++++------ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/packages/video_player/video_player/test/video_player_test.dart b/packages/video_player/video_player/test/video_player_test.dart index f59c9feeca3..c211ce4661b 100644 --- a/packages/video_player/video_player/test/video_player_test.dart +++ b/packages/video_player/video_player/test/video_player_test.dart @@ -788,6 +788,30 @@ void main() { expect(controller.value.position, nonzeroDuration); }); + testWidgets('playback status', (WidgetTester tester) async { + final VideoPlayerController controller = VideoPlayerController.network( + 'https://127.0.0.1', + ); + await controller.initialize(); + expect(controller.value.isPlaying, isFalse); + final StreamController fakeVideoEventStream = + fakeVideoPlayerPlatform.streams[controller.textureId]!; + + fakeVideoEventStream.add(VideoEvent( + eventType: VideoEventType.isPlayingStateUpdate, + isPlaying: true, + )); + await tester.pumpAndSettle(); + expect(controller.value.isPlaying, isTrue); + + fakeVideoEventStream.add(VideoEvent( + eventType: VideoEventType.isPlayingStateUpdate, + isPlaying: false, + )); + await tester.pumpAndSettle(); + expect(controller.value.isPlaying, isFalse); + }); + testWidgets('buffering status', (WidgetTester tester) async { final VideoPlayerController controller = VideoPlayerController.network( 'https://127.0.0.1', 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 28583e0d84a5133453fc08ba560219f1d2521f3d Mon Sep 17 00:00:00 2001 From: maRci002 Date: Sat, 11 Mar 2023 11:29:32 +0100 Subject: [PATCH 11/15] 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 22743640298..b2105e918eb 100644 --- a/packages/video_player/video_player/lib/video_player.dart +++ b/packages/video_player/video_player/lib/video_player.dart @@ -411,7 +411,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 4ba33e6e41a..cea87ba95fa 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 @@ -249,7 +249,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 4ba33e6e41a..cea87ba95fa 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 @@ -249,7 +249,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( From 6cc94b62f8b184a3078400c2bf3f06ea321dbc14 Mon Sep 17 00:00:00 2001 From: maRci002 Date: Sun, 12 Mar 2023 21:37:36 +0100 Subject: [PATCH 12/15] format VideoPlayerTest.java android --- .../plugins/videoplayer/VideoPlayerTest.java | 496 +++++++++--------- 1 file changed, 246 insertions(+), 250 deletions(-) diff --git a/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java b/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java index 6cfca58514f..2ba6ee05388 100644 --- a/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java +++ b/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java @@ -5,8 +5,8 @@ package io.flutter.plugins.videoplayer; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.any; import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.Mockito.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -18,13 +18,10 @@ import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.upstream.DefaultHttpDataSource; - import io.flutter.plugin.common.EventChannel; import io.flutter.view.TextureRegistry; - import java.util.HashMap; import java.util.Map; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -36,250 +33,249 @@ @RunWith(RobolectricTestRunner.class) public class VideoPlayerTest { - private ExoPlayer fakeExoPlayer; - private EventChannel fakeEventChannel; - private TextureRegistry.SurfaceTextureEntry fakeSurfaceTextureEntry; - private VideoPlayerOptions fakeVideoPlayerOptions; - private QueuingEventSink fakeEventSink; - private DefaultHttpDataSource.Factory httpDataSourceFactorySpy; - - @Captor - private ArgumentCaptor> eventCaptor; - - @Before - public void before() { - MockitoAnnotations.openMocks(this); - - fakeExoPlayer = mock(ExoPlayer.class); - fakeEventChannel = mock(EventChannel.class); - fakeSurfaceTextureEntry = mock(TextureRegistry.SurfaceTextureEntry.class); - fakeVideoPlayerOptions = mock(VideoPlayerOptions.class); - fakeEventSink = mock(QueuingEventSink.class); - httpDataSourceFactorySpy = spy(new DefaultHttpDataSource.Factory()); - } - - @Test - public void videoPlayer_buildsHttpDataSourceFactoryProperlyWhenHttpHeadersNull() { - VideoPlayer videoPlayer = - new VideoPlayer( - fakeExoPlayer, - fakeEventChannel, - fakeSurfaceTextureEntry, - fakeVideoPlayerOptions, - fakeEventSink, - httpDataSourceFactorySpy); - - videoPlayer.buildHttpDataSourceFactory(new HashMap<>()); - - verify(httpDataSourceFactorySpy).setUserAgent("ExoPlayer"); - verify(httpDataSourceFactorySpy).setAllowCrossProtocolRedirects(true); - verify(httpDataSourceFactorySpy, never()).setDefaultRequestProperties(any()); - } - - @Test - public void - videoPlayer_buildsHttpDataSourceFactoryProperlyWhenHttpHeadersNonNullAndUserAgentSpecified() { - VideoPlayer videoPlayer = - new VideoPlayer( - fakeExoPlayer, - fakeEventChannel, - fakeSurfaceTextureEntry, - fakeVideoPlayerOptions, - fakeEventSink, - httpDataSourceFactorySpy); - Map httpHeaders = - new HashMap() { - { - put("header", "value"); - put("User-Agent", "userAgent"); - } - }; - - videoPlayer.buildHttpDataSourceFactory(httpHeaders); - - verify(httpDataSourceFactorySpy).setUserAgent("userAgent"); - verify(httpDataSourceFactorySpy).setAllowCrossProtocolRedirects(true); - verify(httpDataSourceFactorySpy).setDefaultRequestProperties(httpHeaders); - } - - @Test - public void - videoPlayer_buildsHttpDataSourceFactoryProperlyWhenHttpHeadersNonNullAndUserAgentNotSpecified() { - VideoPlayer videoPlayer = - new VideoPlayer( - fakeExoPlayer, - fakeEventChannel, - fakeSurfaceTextureEntry, - fakeVideoPlayerOptions, - fakeEventSink, - httpDataSourceFactorySpy); - Map httpHeaders = - new HashMap() { - { - put("header", "value"); - } - }; - - videoPlayer.buildHttpDataSourceFactory(httpHeaders); - - verify(httpDataSourceFactorySpy).setUserAgent("ExoPlayer"); - verify(httpDataSourceFactorySpy).setAllowCrossProtocolRedirects(true); - verify(httpDataSourceFactorySpy).setDefaultRequestProperties(httpHeaders); - } - - @Test - public void sendInitializedSendsExpectedEvent_90RotationDegrees() { - VideoPlayer videoPlayer = - new VideoPlayer( - fakeExoPlayer, - fakeEventChannel, - fakeSurfaceTextureEntry, - fakeVideoPlayerOptions, - fakeEventSink, - httpDataSourceFactorySpy); - Format testFormat = - new Format.Builder().setWidth(100).setHeight(200).setRotationDegrees(90).build(); - - when(fakeExoPlayer.getVideoFormat()).thenReturn(testFormat); - when(fakeExoPlayer.getDuration()).thenReturn(10L); - - videoPlayer.isInitialized = true; - videoPlayer.sendInitialized(); - - verify(fakeEventSink).success(eventCaptor.capture()); - HashMap event = eventCaptor.getValue(); - - assertEquals(event.get("event"), "initialized"); - assertEquals(event.get("duration"), 10L); - assertEquals(event.get("width"), 200); - assertEquals(event.get("height"), 100); - assertEquals(event.get("rotationCorrection"), null); - } - - @Test - public void sendInitializedSendsExpectedEvent_270RotationDegrees() { - VideoPlayer videoPlayer = - new VideoPlayer( - fakeExoPlayer, - fakeEventChannel, - fakeSurfaceTextureEntry, - fakeVideoPlayerOptions, - fakeEventSink, - httpDataSourceFactorySpy); - Format testFormat = - new Format.Builder().setWidth(100).setHeight(200).setRotationDegrees(270).build(); - - when(fakeExoPlayer.getVideoFormat()).thenReturn(testFormat); - when(fakeExoPlayer.getDuration()).thenReturn(10L); - - videoPlayer.isInitialized = true; - videoPlayer.sendInitialized(); - - verify(fakeEventSink).success(eventCaptor.capture()); - HashMap event = eventCaptor.getValue(); - - assertEquals(event.get("event"), "initialized"); - assertEquals(event.get("duration"), 10L); - assertEquals(event.get("width"), 200); - assertEquals(event.get("height"), 100); - assertEquals(event.get("rotationCorrection"), null); - } - - @Test - public void sendInitializedSendsExpectedEvent_0RotationDegrees() { - VideoPlayer videoPlayer = - new VideoPlayer( - fakeExoPlayer, - fakeEventChannel, - fakeSurfaceTextureEntry, - fakeVideoPlayerOptions, - fakeEventSink, - httpDataSourceFactorySpy); - Format testFormat = - new Format.Builder().setWidth(100).setHeight(200).setRotationDegrees(0).build(); - - when(fakeExoPlayer.getVideoFormat()).thenReturn(testFormat); - when(fakeExoPlayer.getDuration()).thenReturn(10L); - - videoPlayer.isInitialized = true; - videoPlayer.sendInitialized(); - - verify(fakeEventSink).success(eventCaptor.capture()); - HashMap event = eventCaptor.getValue(); - - assertEquals(event.get("event"), "initialized"); - assertEquals(event.get("duration"), 10L); - assertEquals(event.get("width"), 100); - assertEquals(event.get("height"), 200); - assertEquals(event.get("rotationCorrection"), null); - } - - @Test - public void sendInitializedSendsExpectedEvent_180RotationDegrees() { - VideoPlayer videoPlayer = - new VideoPlayer( - fakeExoPlayer, - fakeEventChannel, - fakeSurfaceTextureEntry, - fakeVideoPlayerOptions, - fakeEventSink, - httpDataSourceFactorySpy); - Format testFormat = - new Format.Builder().setWidth(100).setHeight(200).setRotationDegrees(180).build(); - - when(fakeExoPlayer.getVideoFormat()).thenReturn(testFormat); - when(fakeExoPlayer.getDuration()).thenReturn(10L); - - videoPlayer.isInitialized = true; - videoPlayer.sendInitialized(); - - verify(fakeEventSink).success(eventCaptor.capture()); - HashMap event = eventCaptor.getValue(); - - assertEquals(event.get("event"), "initialized"); - assertEquals(event.get("duration"), 10L); - assertEquals(event.get("width"), 100); - assertEquals(event.get("height"), 200); - assertEquals(event.get("rotationCorrection"), 180); - } - - @Test - public void onIsPlayingChangedSendsExpectedEvent() { - VideoPlayer videoPlayer = - new VideoPlayer( - fakeExoPlayer, - fakeEventChannel, - fakeSurfaceTextureEntry, - fakeVideoPlayerOptions, - fakeEventSink, - httpDataSourceFactorySpy); - - doAnswer( - (Answer) - invocation -> { - Map event = new HashMap<>(); - event.put("event", "isPlayingStateUpdate"); - event.put("isPlaying", (Boolean) invocation.getArguments()[0]); - fakeEventSink.success(event); - return null; - }) - .when(fakeExoPlayer) - .setPlayWhenReady(anyBoolean()); - - videoPlayer.play(); - - verify(fakeEventSink).success(eventCaptor.capture()); - HashMap event1 = eventCaptor.getValue(); - - assertEquals(event1.get("event"), "isPlayingStateUpdate"); - assertEquals(event1.get("isPlaying"), true); - - videoPlayer.pause(); - - verify(fakeEventSink, times(2)).success(eventCaptor.capture()); - HashMap event2 = eventCaptor.getValue(); - - assertEquals(event2.get("event"), "isPlayingStateUpdate"); - assertEquals(event2.get("isPlaying"), false); - } + private ExoPlayer fakeExoPlayer; + private EventChannel fakeEventChannel; + private TextureRegistry.SurfaceTextureEntry fakeSurfaceTextureEntry; + private VideoPlayerOptions fakeVideoPlayerOptions; + private QueuingEventSink fakeEventSink; + private DefaultHttpDataSource.Factory httpDataSourceFactorySpy; + + @Captor private ArgumentCaptor> eventCaptor; + + @Before + public void before() { + MockitoAnnotations.openMocks(this); + + fakeExoPlayer = mock(ExoPlayer.class); + fakeEventChannel = mock(EventChannel.class); + fakeSurfaceTextureEntry = mock(TextureRegistry.SurfaceTextureEntry.class); + fakeVideoPlayerOptions = mock(VideoPlayerOptions.class); + fakeEventSink = mock(QueuingEventSink.class); + httpDataSourceFactorySpy = spy(new DefaultHttpDataSource.Factory()); + } + + @Test + public void videoPlayer_buildsHttpDataSourceFactoryProperlyWhenHttpHeadersNull() { + VideoPlayer videoPlayer = + new VideoPlayer( + fakeExoPlayer, + fakeEventChannel, + fakeSurfaceTextureEntry, + fakeVideoPlayerOptions, + fakeEventSink, + httpDataSourceFactorySpy); + + videoPlayer.buildHttpDataSourceFactory(new HashMap<>()); + + verify(httpDataSourceFactorySpy).setUserAgent("ExoPlayer"); + verify(httpDataSourceFactorySpy).setAllowCrossProtocolRedirects(true); + verify(httpDataSourceFactorySpy, never()).setDefaultRequestProperties(any()); + } + + @Test + public void + videoPlayer_buildsHttpDataSourceFactoryProperlyWhenHttpHeadersNonNullAndUserAgentSpecified() { + VideoPlayer videoPlayer = + new VideoPlayer( + fakeExoPlayer, + fakeEventChannel, + fakeSurfaceTextureEntry, + fakeVideoPlayerOptions, + fakeEventSink, + httpDataSourceFactorySpy); + Map httpHeaders = + new HashMap() { + { + put("header", "value"); + put("User-Agent", "userAgent"); + } + }; + + videoPlayer.buildHttpDataSourceFactory(httpHeaders); + + verify(httpDataSourceFactorySpy).setUserAgent("userAgent"); + verify(httpDataSourceFactorySpy).setAllowCrossProtocolRedirects(true); + verify(httpDataSourceFactorySpy).setDefaultRequestProperties(httpHeaders); + } + + @Test + public void + videoPlayer_buildsHttpDataSourceFactoryProperlyWhenHttpHeadersNonNullAndUserAgentNotSpecified() { + VideoPlayer videoPlayer = + new VideoPlayer( + fakeExoPlayer, + fakeEventChannel, + fakeSurfaceTextureEntry, + fakeVideoPlayerOptions, + fakeEventSink, + httpDataSourceFactorySpy); + Map httpHeaders = + new HashMap() { + { + put("header", "value"); + } + }; + + videoPlayer.buildHttpDataSourceFactory(httpHeaders); + + verify(httpDataSourceFactorySpy).setUserAgent("ExoPlayer"); + verify(httpDataSourceFactorySpy).setAllowCrossProtocolRedirects(true); + verify(httpDataSourceFactorySpy).setDefaultRequestProperties(httpHeaders); + } + + @Test + public void sendInitializedSendsExpectedEvent_90RotationDegrees() { + VideoPlayer videoPlayer = + new VideoPlayer( + fakeExoPlayer, + fakeEventChannel, + fakeSurfaceTextureEntry, + fakeVideoPlayerOptions, + fakeEventSink, + httpDataSourceFactorySpy); + Format testFormat = + new Format.Builder().setWidth(100).setHeight(200).setRotationDegrees(90).build(); + + when(fakeExoPlayer.getVideoFormat()).thenReturn(testFormat); + when(fakeExoPlayer.getDuration()).thenReturn(10L); + + videoPlayer.isInitialized = true; + videoPlayer.sendInitialized(); + + verify(fakeEventSink).success(eventCaptor.capture()); + HashMap event = eventCaptor.getValue(); + + assertEquals(event.get("event"), "initialized"); + assertEquals(event.get("duration"), 10L); + assertEquals(event.get("width"), 200); + assertEquals(event.get("height"), 100); + assertEquals(event.get("rotationCorrection"), null); + } + + @Test + public void sendInitializedSendsExpectedEvent_270RotationDegrees() { + VideoPlayer videoPlayer = + new VideoPlayer( + fakeExoPlayer, + fakeEventChannel, + fakeSurfaceTextureEntry, + fakeVideoPlayerOptions, + fakeEventSink, + httpDataSourceFactorySpy); + Format testFormat = + new Format.Builder().setWidth(100).setHeight(200).setRotationDegrees(270).build(); + + when(fakeExoPlayer.getVideoFormat()).thenReturn(testFormat); + when(fakeExoPlayer.getDuration()).thenReturn(10L); + + videoPlayer.isInitialized = true; + videoPlayer.sendInitialized(); + + verify(fakeEventSink).success(eventCaptor.capture()); + HashMap event = eventCaptor.getValue(); + + assertEquals(event.get("event"), "initialized"); + assertEquals(event.get("duration"), 10L); + assertEquals(event.get("width"), 200); + assertEquals(event.get("height"), 100); + assertEquals(event.get("rotationCorrection"), null); + } + + @Test + public void sendInitializedSendsExpectedEvent_0RotationDegrees() { + VideoPlayer videoPlayer = + new VideoPlayer( + fakeExoPlayer, + fakeEventChannel, + fakeSurfaceTextureEntry, + fakeVideoPlayerOptions, + fakeEventSink, + httpDataSourceFactorySpy); + Format testFormat = + new Format.Builder().setWidth(100).setHeight(200).setRotationDegrees(0).build(); + + when(fakeExoPlayer.getVideoFormat()).thenReturn(testFormat); + when(fakeExoPlayer.getDuration()).thenReturn(10L); + + videoPlayer.isInitialized = true; + videoPlayer.sendInitialized(); + + verify(fakeEventSink).success(eventCaptor.capture()); + HashMap event = eventCaptor.getValue(); + + assertEquals(event.get("event"), "initialized"); + assertEquals(event.get("duration"), 10L); + assertEquals(event.get("width"), 100); + assertEquals(event.get("height"), 200); + assertEquals(event.get("rotationCorrection"), null); + } + + @Test + public void sendInitializedSendsExpectedEvent_180RotationDegrees() { + VideoPlayer videoPlayer = + new VideoPlayer( + fakeExoPlayer, + fakeEventChannel, + fakeSurfaceTextureEntry, + fakeVideoPlayerOptions, + fakeEventSink, + httpDataSourceFactorySpy); + Format testFormat = + new Format.Builder().setWidth(100).setHeight(200).setRotationDegrees(180).build(); + + when(fakeExoPlayer.getVideoFormat()).thenReturn(testFormat); + when(fakeExoPlayer.getDuration()).thenReturn(10L); + + videoPlayer.isInitialized = true; + videoPlayer.sendInitialized(); + + verify(fakeEventSink).success(eventCaptor.capture()); + HashMap event = eventCaptor.getValue(); + + assertEquals(event.get("event"), "initialized"); + assertEquals(event.get("duration"), 10L); + assertEquals(event.get("width"), 100); + assertEquals(event.get("height"), 200); + assertEquals(event.get("rotationCorrection"), 180); + } + + @Test + public void onIsPlayingChangedSendsExpectedEvent() { + VideoPlayer videoPlayer = + new VideoPlayer( + fakeExoPlayer, + fakeEventChannel, + fakeSurfaceTextureEntry, + fakeVideoPlayerOptions, + fakeEventSink, + httpDataSourceFactorySpy); + + doAnswer( + (Answer) + invocation -> { + Map event = new HashMap<>(); + event.put("event", "isPlayingStateUpdate"); + event.put("isPlaying", (Boolean) invocation.getArguments()[0]); + fakeEventSink.success(event); + return null; + }) + .when(fakeExoPlayer) + .setPlayWhenReady(anyBoolean()); + + videoPlayer.play(); + + verify(fakeEventSink).success(eventCaptor.capture()); + HashMap event1 = eventCaptor.getValue(); + + assertEquals(event1.get("event"), "isPlayingStateUpdate"); + assertEquals(event1.get("isPlaying"), true); + + videoPlayer.pause(); + + verify(fakeEventSink, times(2)).success(eventCaptor.capture()); + HashMap event2 = eventCaptor.getValue(); + + assertEquals(event2.get("event"), "isPlayingStateUpdate"); + assertEquals(event2.get("isPlaying"), false); + } } From cf16cb3c6f71c71e3ecc130583cf0f6c94971b1d Mon Sep 17 00:00:00 2001 From: maRci002 Date: Sun, 12 Mar 2023 23:16:05 +0100 Subject: [PATCH 13/15] add version changes to iOS / web --- packages/video_player/video_player_avfoundation/CHANGELOG.md | 5 ++++- packages/video_player/video_player_avfoundation/pubspec.yaml | 2 +- packages/video_player/video_player_web/CHANGELOG.md | 5 ++++- packages/video_player/video_player_web/pubspec.yaml | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/video_player/video_player_avfoundation/CHANGELOG.md b/packages/video_player/video_player_avfoundation/CHANGELOG.md index fb9d55f4fd7..47102ed5a90 100644 --- a/packages/video_player/video_player_avfoundation/CHANGELOG.md +++ b/packages/video_player/video_player_avfoundation/CHANGELOG.md @@ -1,8 +1,11 @@ +## 2.4.2 + +* Synchronizes `VideoPlayerValue.isPlaying` with `AVPlayer`. + ## 2.4.1 * Clarifies explanation of endorsement in README. * Aligns Dart and Flutter SDK constraints. -* Synchronizes `VideoPlayerValue.isPlaying` with `AVPlayer`. ## 2.4.0 diff --git a/packages/video_player/video_player_avfoundation/pubspec.yaml b/packages/video_player/video_player_avfoundation/pubspec.yaml index adcd67e0343..12a6b2da152 100644 --- a/packages/video_player/video_player_avfoundation/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/pubspec.yaml @@ -2,7 +2,7 @@ name: video_player_avfoundation description: iOS implementation of the video_player plugin. repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_avfoundation issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 -version: 2.4.1 +version: 2.4.2 environment: sdk: ">=2.18.0 <3.0.0" diff --git a/packages/video_player/video_player_web/CHANGELOG.md b/packages/video_player/video_player_web/CHANGELOG.md index a6f7d5e99c7..19f5bb927f2 100644 --- a/packages/video_player/video_player_web/CHANGELOG.md +++ b/packages/video_player/video_player_web/CHANGELOG.md @@ -1,8 +1,11 @@ +## 2.0.16 + +* Synchronizes `VideoPlayerValue.isPlaying` with `VideoElement`. + ## 2.0.15 * Clarifies explanation of endorsement in README. * Aligns Dart and Flutter SDK constraints. -* Synchronizes `VideoPlayerValue.isPlaying` with `VideoElement`. ## 2.0.14 diff --git a/packages/video_player/video_player_web/pubspec.yaml b/packages/video_player/video_player_web/pubspec.yaml index a07d6547a41..dd22391557d 100644 --- a/packages/video_player/video_player_web/pubspec.yaml +++ b/packages/video_player/video_player_web/pubspec.yaml @@ -2,7 +2,7 @@ name: video_player_web description: Web platform implementation of video_player. repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 -version: 2.0.15 +version: 2.0.16 environment: sdk: ">=2.17.0 <3.0.0" From 12507c2d826c9c9467e0e9ddde85a79ff8c457ad Mon Sep 17 00:00:00 2001 From: maRci002 Date: Thu, 16 Mar 2023 15:52:43 +0100 Subject: [PATCH 14/15] remove dependency_overrides --- packages/camera/camera/example/pubspec.yaml | 8 -------- packages/camera/camera/pubspec.yaml | 8 -------- packages/camera/camera_android/example/pubspec.yaml | 8 -------- .../camera_android_camerax/example/pubspec.yaml | 8 -------- .../camera/camera_avfoundation/example/pubspec.yaml | 8 -------- .../image_picker/image_picker/example/pubspec.yaml | 8 -------- .../image_picker_android/example/pubspec.yaml | 8 -------- .../image_picker_ios/example/pubspec.yaml | 8 -------- .../image_picker_windows/example/pubspec.yaml | 8 -------- .../video_player/video_player/example/pubspec.yaml | 5 ----- packages/video_player/video_player/pubspec.yaml | 11 ----------- .../video_player_android/example/pubspec.yaml | 5 ----- .../video_player/video_player_android/pubspec.yaml | 5 ----- .../video_player_avfoundation/example/pubspec.yaml | 5 ----- .../video_player_avfoundation/pubspec.yaml | 5 ----- .../video_player_web/example/pubspec.yaml | 5 ----- packages/video_player/video_player_web/pubspec.yaml | 5 ----- 17 files changed, 118 deletions(-) diff --git a/packages/camera/camera/example/pubspec.yaml b/packages/camera/camera/example/pubspec.yaml index 93e75b8fedf..9841d0adfa6 100644 --- a/packages/camera/camera/example/pubspec.yaml +++ b/packages/camera/camera/example/pubspec.yaml @@ -30,11 +30,3 @@ dev_dependencies: flutter: uses-material-design: true - - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player: - path: ../../../video_player/video_player - video_player_platform_interface: - path: ../../../video_player/video_player_platform_interface diff --git a/packages/camera/camera/pubspec.yaml b/packages/camera/camera/pubspec.yaml index 8808d6cb9ba..e084b0c33a2 100644 --- a/packages/camera/camera/pubspec.yaml +++ b/packages/camera/camera/pubspec.yaml @@ -38,11 +38,3 @@ dev_dependencies: mockito: ^5.0.0 plugin_platform_interface: ^2.0.0 video_player: ^2.0.0 - - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player: - path: ../../video_player/video_player - video_player_platform_interface: - path: ../../video_player/video_player_platform_interface diff --git a/packages/camera/camera_android/example/pubspec.yaml b/packages/camera/camera_android/example/pubspec.yaml index 15c52d11cb6..aacd47f6773 100644 --- a/packages/camera/camera_android/example/pubspec.yaml +++ b/packages/camera/camera_android/example/pubspec.yaml @@ -32,11 +32,3 @@ dev_dependencies: flutter: uses-material-design: true - - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player: - path: ../../../video_player/video_player - video_player_platform_interface: - path: ../../../video_player/video_player_platform_interface diff --git a/packages/camera/camera_android_camerax/example/pubspec.yaml b/packages/camera/camera_android_camerax/example/pubspec.yaml index f995f2357ce..49a29b8517d 100644 --- a/packages/camera/camera_android_camerax/example/pubspec.yaml +++ b/packages/camera/camera_android_camerax/example/pubspec.yaml @@ -27,11 +27,3 @@ dev_dependencies: flutter: uses-material-design: true - - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player: - path: ../../../video_player/video_player - video_player_platform_interface: - path: ../../../video_player/video_player_platform_interface diff --git a/packages/camera/camera_avfoundation/example/pubspec.yaml b/packages/camera/camera_avfoundation/example/pubspec.yaml index 2c8fc744be3..0c471ff4848 100644 --- a/packages/camera/camera_avfoundation/example/pubspec.yaml +++ b/packages/camera/camera_avfoundation/example/pubspec.yaml @@ -32,11 +32,3 @@ dev_dependencies: flutter: uses-material-design: true - - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player: - path: ../../../video_player/video_player - video_player_platform_interface: - path: ../../../video_player/video_player_platform_interface diff --git a/packages/image_picker/image_picker/example/pubspec.yaml b/packages/image_picker/image_picker/example/pubspec.yaml index 1c1e16d896e..11d9837e619 100755 --- a/packages/image_picker/image_picker/example/pubspec.yaml +++ b/packages/image_picker/image_picker/example/pubspec.yaml @@ -30,11 +30,3 @@ dev_dependencies: flutter: uses-material-design: true - - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player: - path: ../../../video_player/video_player - video_player_platform_interface: - path: ../../../video_player/video_player_platform_interface diff --git a/packages/image_picker/image_picker_android/example/pubspec.yaml b/packages/image_picker/image_picker_android/example/pubspec.yaml index 819a36c2fe1..52778a441eb 100644 --- a/packages/image_picker/image_picker_android/example/pubspec.yaml +++ b/packages/image_picker/image_picker_android/example/pubspec.yaml @@ -32,11 +32,3 @@ dev_dependencies: flutter: uses-material-design: true - - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player: - path: ../../../video_player/video_player - video_player_platform_interface: - path: ../../../video_player/video_player_platform_interface diff --git a/packages/image_picker/image_picker_ios/example/pubspec.yaml b/packages/image_picker/image_picker_ios/example/pubspec.yaml index ef3bae045c9..11353d8bb48 100755 --- a/packages/image_picker/image_picker_ios/example/pubspec.yaml +++ b/packages/image_picker/image_picker_ios/example/pubspec.yaml @@ -29,11 +29,3 @@ dev_dependencies: flutter: uses-material-design: true - - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player: - path: ../../../video_player/video_player - video_player_platform_interface: - path: ../../../video_player/video_player_platform_interface diff --git a/packages/image_picker/image_picker_windows/example/pubspec.yaml b/packages/image_picker/image_picker_windows/example/pubspec.yaml index 9bb43227c20..4130ec84ff0 100644 --- a/packages/image_picker/image_picker_windows/example/pubspec.yaml +++ b/packages/image_picker/image_picker_windows/example/pubspec.yaml @@ -26,11 +26,3 @@ dev_dependencies: flutter: uses-material-design: true - - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player: - path: ../../../video_player/video_player - video_player_platform_interface: - path: ../../../video_player/video_player_platform_interface diff --git a/packages/video_player/video_player/example/pubspec.yaml b/packages/video_player/video_player/example/pubspec.yaml index 4d3c48d2a8d..f29edfb0b0a 100644 --- a/packages/video_player/video_player/example/pubspec.yaml +++ b/packages/video_player/video_player/example/pubspec.yaml @@ -37,8 +37,3 @@ flutter: - assets/bumble_bee_captions.srt - assets/bumble_bee_captions.vtt - assets/Audio.mp3 - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player_platform_interface: - path: ../../video_player_platform_interface diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index 9a40de841f0..96f761529fe 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -31,14 +31,3 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player_android: - path: ../video_player_android - video_player_avfoundation: - path: ../video_player_avfoundation - video_player_platform_interface: - path: ../video_player_platform_interface - video_player_web: - path: ../video_player_web diff --git a/packages/video_player/video_player_android/example/pubspec.yaml b/packages/video_player/video_player_android/example/pubspec.yaml index 7d26461700c..0100ee1d916 100644 --- a/packages/video_player/video_player_android/example/pubspec.yaml +++ b/packages/video_player/video_player_android/example/pubspec.yaml @@ -33,8 +33,3 @@ flutter: assets: - assets/flutter-mark-square-64.png - assets/Butterfly-209.mp4 - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player_platform_interface: - path: ../../video_player_platform_interface diff --git a/packages/video_player/video_player_android/pubspec.yaml b/packages/video_player/video_player_android/pubspec.yaml index a88c0516009..598dfe1e6be 100644 --- a/packages/video_player/video_player_android/pubspec.yaml +++ b/packages/video_player/video_player_android/pubspec.yaml @@ -26,8 +26,3 @@ dev_dependencies: flutter_test: sdk: flutter pigeon: ^2.0.1 - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player_platform_interface: - path: ../video_player_platform_interface diff --git a/packages/video_player/video_player_avfoundation/example/pubspec.yaml b/packages/video_player/video_player_avfoundation/example/pubspec.yaml index 2e4785cf283..04ae207185e 100644 --- a/packages/video_player/video_player_avfoundation/example/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/example/pubspec.yaml @@ -33,8 +33,3 @@ flutter: assets: - assets/flutter-mark-square-64.png - assets/Butterfly-209.mp4 - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player_platform_interface: - path: ../../video_player_platform_interface diff --git a/packages/video_player/video_player_avfoundation/pubspec.yaml b/packages/video_player/video_player_avfoundation/pubspec.yaml index dc4812c7250..f09c4e7507e 100644 --- a/packages/video_player/video_player_avfoundation/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/pubspec.yaml @@ -25,8 +25,3 @@ dev_dependencies: flutter_test: sdk: flutter pigeon: ^8.0.0 - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player_platform_interface: - path: ../video_player_platform_interface diff --git a/packages/video_player/video_player_web/example/pubspec.yaml b/packages/video_player/video_player_web/example/pubspec.yaml index 9b579321476..3c51cab6e21 100644 --- a/packages/video_player/video_player_web/example/pubspec.yaml +++ b/packages/video_player/video_player_web/example/pubspec.yaml @@ -20,8 +20,3 @@ dev_dependencies: sdk: flutter integration_test: sdk: flutter - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player_platform_interface: - path: ../../video_player_platform_interface diff --git a/packages/video_player/video_player_web/pubspec.yaml b/packages/video_player/video_player_web/pubspec.yaml index dd22391557d..8c3e420aaa3 100644 --- a/packages/video_player/video_player_web/pubspec.yaml +++ b/packages/video_player/video_player_web/pubspec.yaml @@ -26,8 +26,3 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - -# FOR TESTING ONLY. DO NOT MERGE. -dependency_overrides: - video_player_platform_interface: - path: ../video_player_platform_interface From 810b83e42bbcb239a00f75a841c09133ac2b0fdf Mon Sep 17 00:00:00 2001 From: maRci002 Date: Thu, 16 Mar 2023 16:20:59 +0100 Subject: [PATCH 15/15] upgrade video_player_platform_interface dependency versions to 6.1.0 --- packages/video_player/video_player/pubspec.yaml | 2 +- packages/video_player/video_player_android/example/pubspec.yaml | 2 +- packages/video_player/video_player_android/pubspec.yaml | 2 +- .../video_player/video_player_avfoundation/example/pubspec.yaml | 2 +- packages/video_player/video_player_avfoundation/pubspec.yaml | 2 +- packages/video_player/video_player_web/example/pubspec.yaml | 2 +- packages/video_player/video_player_web/pubspec.yaml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index 96f761529fe..04ddb0e6f32 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: html: ^0.15.0 video_player_android: ^2.3.5 video_player_avfoundation: ^2.2.17 - video_player_platform_interface: ">=5.1.1 <7.0.0" + video_player_platform_interface: ">=6.1.0 <7.0.0" video_player_web: ^2.0.0 dev_dependencies: diff --git a/packages/video_player/video_player_android/example/pubspec.yaml b/packages/video_player/video_player_android/example/pubspec.yaml index 0100ee1d916..b761601b66c 100644 --- a/packages/video_player/video_player_android/example/pubspec.yaml +++ b/packages/video_player/video_player_android/example/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: # The example app is bundled with the plugin so we use a path dependency on # the parent directory to use the current plugin's version. path: ../ - video_player_platform_interface: ">=5.1.1 <7.0.0" + video_player_platform_interface: ">=6.1.0 <7.0.0" dev_dependencies: flutter_driver: diff --git a/packages/video_player/video_player_android/pubspec.yaml b/packages/video_player/video_player_android/pubspec.yaml index 598dfe1e6be..99b17e718f5 100644 --- a/packages/video_player/video_player_android/pubspec.yaml +++ b/packages/video_player/video_player_android/pubspec.yaml @@ -20,7 +20,7 @@ flutter: dependencies: flutter: sdk: flutter - video_player_platform_interface: ">=5.1.1 <7.0.0" + video_player_platform_interface: ">=6.1.0 <7.0.0" dev_dependencies: flutter_test: diff --git a/packages/video_player/video_player_avfoundation/example/pubspec.yaml b/packages/video_player/video_player_avfoundation/example/pubspec.yaml index 04ae207185e..cc1ec198bc7 100644 --- a/packages/video_player/video_player_avfoundation/example/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/example/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: # The example app is bundled with the plugin so we use a path dependency on # the parent directory to use the current plugin's version. path: ../ - video_player_platform_interface: ">=4.2.0 <7.0.0" + video_player_platform_interface: ">=6.1.0 <7.0.0" dev_dependencies: flutter_driver: diff --git a/packages/video_player/video_player_avfoundation/pubspec.yaml b/packages/video_player/video_player_avfoundation/pubspec.yaml index f09c4e7507e..e1cb304664a 100644 --- a/packages/video_player/video_player_avfoundation/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/pubspec.yaml @@ -19,7 +19,7 @@ flutter: dependencies: flutter: sdk: flutter - video_player_platform_interface: ">=4.2.0 <7.0.0" + video_player_platform_interface: ">=6.1.0 <7.0.0" dev_dependencies: flutter_test: diff --git a/packages/video_player/video_player_web/example/pubspec.yaml b/packages/video_player/video_player_web/example/pubspec.yaml index 3c51cab6e21..813241e5d67 100644 --- a/packages/video_player/video_player_web/example/pubspec.yaml +++ b/packages/video_player/video_player_web/example/pubspec.yaml @@ -9,7 +9,7 @@ dependencies: flutter: sdk: flutter js: ^0.6.0 - video_player_platform_interface: ">=4.2.0 <7.0.0" + video_player_platform_interface: ">=6.1.0 <7.0.0" video_player_web: path: ../ diff --git a/packages/video_player/video_player_web/pubspec.yaml b/packages/video_player/video_player_web/pubspec.yaml index 8c3e420aaa3..f2beb350b2d 100644 --- a/packages/video_player/video_player_web/pubspec.yaml +++ b/packages/video_player/video_player_web/pubspec.yaml @@ -21,7 +21,7 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - video_player_platform_interface: ">=4.2.0 <7.0.0" + video_player_platform_interface: ">=6.1.0 <7.0.0" dev_dependencies: flutter_test: