Bläddra i källkod

Refactor pause logic in VidPlayerController and add playOver method

gavin.chen 1 år sedan
förälder
incheckning
1fecf45cc8
2 ändrade filer med 11 tillägg och 1 borttagningar
  1. 7 1
      lib/view/player/controller_old.dart
  2. 4 0
      lib/view/player/events.dart

+ 7 - 1
lib/view/player/controller_old.dart

@@ -162,6 +162,12 @@ class VidPlayerControllerNoSharing extends ChangeNotifier
     _setStatus(VidPlayStatus.pause);
   }
 
+  /// 主动播放结束
+  void playOver() {
+    pause();
+    eventHandler.emit(this, VidPlayerPlayOverEvent());
+  }
+
   /// Pause and view next frame
   Future<bool> gotoNextFrame() {
     pause();
@@ -374,7 +380,7 @@ class _PlayAssistant {
       // print('play at  ${DateTime.now()}');
       owner.gotoFrame(owner.currentFrameIndex + 1);
       if (owner.currentFrameIndex == owner.totalFramesCount - 1) {
-        owner.pause();
+        owner.playOver();
       }
     });
   }

+ 4 - 0
lib/view/player/events.dart

@@ -45,3 +45,7 @@ class VidPlayerFilterChangeEvent extends VidPlayerEvent {
 class VidPlayResetToneEvent extends VidPlayerEvent {
   VidPlayResetToneEvent();
 }
+
+class VidPlayerPlayOverEvent extends VidPlayerEvent {
+  VidPlayerPlayOverEvent();
+}