AnonymHK / betterplayer

Bug fix version for betterplayer
Apache License 2.0
42 stars 32 forks source link

[BUG] BetterPlayerEventType.finished arrives twice #21

Open guyluz11 opened 11 months ago

guyluz11 commented 11 months ago

Describe the bug

The value BetterPlayerEventType.finished arrives twice in the callback addEventsListener when video is completed using skeepTo function

To Reproduce Steps to reproduce the behavior:

  1. Added controller.addEventsListener(myFunction); for the video
  2. Add the function like this
    void myFunction(BetterPlayerEvent event) {
    if (event.betterPlayerEventType == BetterPlayerEventType.finished) {
    print('Video finished');
    }
    }
  3. Add a skip forward button with the code controller.seekTo(videoPosition + Duration(seconds: 10));
  4. Jump to the end of the video by pressing the skip button a couple of times
  5. "Video finished" text will be printed to the console more then once

*Example code Paste here your minimal reproducible code. This code should be ready to copy-paste-run.

Expected behavior addEventsListener should call the event function only once with BetterPlayerEventType.finished

Screenshots If applicable, add screenshots to help explain your problem.

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.10.2, on Ubuntu 23.04 6.3.6-060306-generic, locale en_IL) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Chrome - develop for the web [✓] Linux toolchain - develop for Linux desktop [✓] Android Studio (version 2022.2) [✓] Android Studio (version 2021.3) [✓] VS Code [✓] Connected device (3 available) [✓] Network resources

• No issues found!

Better Player version

Smartphone (please complete the following information): Android emulator

Additional context Add any other context about the problem here.