From 09fa2c6f6cb2504df2c8333b90ebacf3f74f837e Mon Sep 17 00:00:00 2001 From: Nour Date: Wed, 8 Mar 2023 18:46:14 +0300 Subject: [PATCH] adds isCompleted --- brightcove_flutter/lib/brightcove_flutter.dart | 12 +++++++++++- brightcove_flutter/pubspec.yaml | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/brightcove_flutter/lib/brightcove_flutter.dart b/brightcove_flutter/lib/brightcove_flutter.dart index ff109dd..cf26077 100644 --- a/brightcove_flutter/lib/brightcove_flutter.dart +++ b/brightcove_flutter/lib/brightcove_flutter.dart @@ -36,6 +36,7 @@ class VideoPlayerValue { this.size = Size.zero, this.position = Duration.zero, this.isInitialized = false, + this.isCompleted = false, this.isPlaying = false, this.isLooping = false, this.isBuffering = false, @@ -94,6 +95,9 @@ class VideoPlayerValue { /// Indicates whether or not the video has been loaded and is ready to play. final bool isInitialized; + /// True if video has completed playing + final bool isCompleted; + /// Indicates if the player auto-plays // final bool isAutoPlay; @@ -128,6 +132,7 @@ class VideoPlayerValue { Duration? position, Duration? captionOffset, bool? isInitialized, + bool? isCompleted, bool? isPlaying, bool? isLooping, bool? isBuffering, @@ -142,6 +147,7 @@ class VideoPlayerValue { size: size ?? this.size, position: position ?? this.position, isInitialized: isInitialized ?? this.isInitialized, + isCompleted: isCompleted ?? this.isCompleted, isPlaying: isPlaying ?? this.isPlaying, isLooping: isLooping ?? this.isLooping, isBuffering: isBuffering ?? this.isBuffering, @@ -160,6 +166,7 @@ class VideoPlayerValue { 'size: $size, ' 'position: $position, ' 'isInitialized: $isInitialized, ' + 'isCompleted: $isCompleted, ' 'isPlaying: $isPlaying, ' 'isLooping: $isLooping, ' 'isBuffering: $isBuffering, ' @@ -171,6 +178,7 @@ class VideoPlayerValue { bool operator ==(other) { return (other is VideoPlayerValue && other.isInitialized == isInitialized && + other.isCompleted == isCompleted && other.isLooping == isLooping && other.isBuffering == isBuffering && other.volume == volume && @@ -184,6 +192,7 @@ class VideoPlayerValue { @override int get hashCode => Object.hash( isInitialized, + isCompleted, isPlaying, isLooping, volume, @@ -245,11 +254,12 @@ class BrightcoveVideoPlayerController extends ValueNotifier { print("[listener][position]${event.currentPosition}"); value = value.copyWith( position: Duration( - milliseconds: ((event.currentPosition ?? 0) as int), + milliseconds: (event.currentPosition ?? 0), )); break; case VideoEventType.completed: pause().then((_) => seekTo(value.duration)); + value = value.copyWith(isCompleted: true); break; case VideoEventType.bufferingStart: value = value.copyWith(isBuffering: true); diff --git a/brightcove_flutter/pubspec.yaml b/brightcove_flutter/pubspec.yaml index bb1f797..031cfcd 100644 --- a/brightcove_flutter/pubspec.yaml +++ b/brightcove_flutter/pubspec.yaml @@ -23,13 +23,13 @@ dependencies: git: url: https://github.com/BlinxTeam/brightcove_flutter.git path: brightcove_android - ref: v0.2.3 + ref: v0.2.4 brightcove_ios: # path: ../brightcove_ios git: url: https://github.com/BlinxTeam/brightcove_flutter.git path: brightcove_ios - ref: v0.2.3 + ref: v0.2.4 dependency_overrides: brightcove_flutter_platform_interface: