diff --git a/packages/video_player_avplay/CHANGELOG.md b/packages/video_player_avplay/CHANGELOG.md index 8d8ba091e..0f4efed92 100644 --- a/packages/video_player_avplay/CHANGELOG.md +++ b/packages/video_player_avplay/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.3 + +* Add 'isCompleted' event to 'VideoPlayerEvent'. + ## 0.5.2 * Add start position in player options when creating player. This is useful for resuming playback from last viewed position. diff --git a/packages/video_player_avplay/README.md b/packages/video_player_avplay/README.md index c30d6df00..398b509c1 100644 --- a/packages/video_player_avplay/README.md +++ b/packages/video_player_avplay/README.md @@ -12,7 +12,7 @@ To use this package, add `video_player_avplay` as a dependency in your `pubspec. ```yaml dependencies: - video_player_avplay: ^0.5.2 + video_player_avplay: ^0.5.3 ``` Then you can import `video_player_avplay` in your Dart code: diff --git a/packages/video_player_avplay/lib/video_player.dart b/packages/video_player_avplay/lib/video_player.dart index eb141098b..4428e2985 100644 --- a/packages/video_player_avplay/lib/video_player.dart +++ b/packages/video_player_avplay/lib/video_player.dart @@ -53,6 +53,7 @@ class VideoPlayerValue { this.volume = 1.0, this.playbackSpeed = 1.0, this.errorDescription, + this.isCompleted = false, }); /// Returns an instance for a video that hasn't been loaded. @@ -117,6 +118,12 @@ class VideoPlayerValue { /// If [hasError] is false this is `null`. final String? errorDescription; + /// True if video has finished playing to end. + /// + /// Reverts to false if video position changes, or video begins playing. + /// Does not update if video is looping. + final bool isCompleted; + /// The [size] of the currently loaded video. final Size size; @@ -161,6 +168,7 @@ class VideoPlayerValue { double? volume, double? playbackSpeed, String? errorDescription = _defaultErrorDescription, + bool? isCompleted, }) { return VideoPlayerValue( duration: duration ?? this.duration, @@ -179,6 +187,7 @@ class VideoPlayerValue { errorDescription: errorDescription != _defaultErrorDescription ? errorDescription : this.errorDescription, + isCompleted: isCompleted ?? this.isCompleted, ); } @@ -198,7 +207,8 @@ class VideoPlayerValue { 'isBuffering: $isBuffering, ' 'volume: $volume, ' 'playbackSpeed: $playbackSpeed, ' - 'errorDescription: $errorDescription)'; + 'errorDescription: $errorDescription, ' + 'isCompleted: $isCompleted),'; } } @@ -421,7 +431,18 @@ class VideoPlayerController extends ValueNotifier { size: event.size, isInitialized: event.duration != null, errorDescription: null, + isCompleted: false, ); + assert( + !initializingCompleter.isCompleted, + 'VideoPlayerController already initialized. This is typically a ' + 'sign that an implementation of the VideoPlayerPlatform ' + '(${_videoPlayerPlatform.runtimeType}) has a bug and is sending ' + 'more than one initialized event per instance.', + ); + if (initializingCompleter.isCompleted) { + throw StateError('VideoPlayerController already initialized'); + } initializingCompleter.complete(null); _applyLooping(); // NOTE(jsuya): The plusplayer's SetVolume() work when player is @@ -437,6 +458,7 @@ class VideoPlayerController extends ValueNotifier { // we use pause() and seekTo() to ensure the platform stops playing // and seeks to the last frame of the video. pause().then((void pauseResult) => seekTo(value.duration.end)); + value = value.copyWith(isCompleted: true); _durationTimer?.cancel(); case VideoEventType.bufferingUpdate: value = value.copyWith(buffered: event.buffered); @@ -811,6 +833,7 @@ class VideoPlayerController extends ValueNotifier { value = value.copyWith( position: position, caption: _getCaptionAt(position), + isCompleted: position == value.duration.end, ); } diff --git a/packages/video_player_avplay/pubspec.yaml b/packages/video_player_avplay/pubspec.yaml index ece943881..c288963f6 100644 --- a/packages/video_player_avplay/pubspec.yaml +++ b/packages/video_player_avplay/pubspec.yaml @@ -2,7 +2,7 @@ name: video_player_avplay description: Flutter plugin for displaying inline video on Tizen TV devices. homepage: https://github.com/flutter-tizen/plugins repository: https://github.com/flutter-tizen/plugins/tree/master/packages/video_player_avplay -version: 0.5.2 +version: 0.5.3 environment: sdk: ">=3.1.0 <4.0.0"