Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Event.PlaybackQueueEnded fires before adding tracks to the queue (v2.0.1) #1229

Closed
alexcastillo opened this issue Aug 12, 2021 · 4 comments
Labels
Milestone

Comments

@alexcastillo
Copy link

Hi there,

Thank you much for this project, this is exactly what I was looking for. I tried other libraries and this one is the best so far.

Describe the bug
Subscribing to the Event.PlaybackQueueEnded event via the useTrackPlayerEvents hook fires an event before adding tracks to the queue. This happens in Android only.

Current workaround:

 useTrackPlayerEvents([Event.PlaybackQueueEnded], (event) => {
    const { position, track } = event;

    // @android-fix
    if (!track && position === 0) {
      console.log("Skipping first queue ended event that happens in Android", event);
      return;
    }

    // Queue really ended...
});

Environment (please complete the following information):
Run react-native info in your project and share the content.
What react-native-track-player version are you using? v2.0.1
Are you testing on a real device or in the simulator? Which OS version are you running? real device: Google Pixel 4a

System:
    OS: macOS 11.4
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 48.41 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.16.1 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.15.1 - /usr/local/bin/npm
    Watchman: 2021.05.31.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 29.0.3
      System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.2 AI-202.7660.26.42.7351085
    Xcode: 12.5/12E262 - /usr/bin/xcodebuild
  Languages:
    Java: 15.0.1 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^17.0.1 => 17.0.1 
    react-native: ^0.63.4 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Code
Please, share the code that is causing the issue:

useTrackPlayerEvents([Event.PlaybackQueueEnded], (event) => {
  // Fires before adding tracks to the queue in Android, and not in iOS
});
@dcvz
Copy link
Contributor

dcvz commented Aug 18, 2021

Thanks for the report @alexcastillo ! We'll try to replicate soon

@dcvz
Copy link
Contributor

dcvz commented Aug 19, 2021

Thanks for reporting this @alexcastillo, this has now been fixed in 2037263 and should go out in the next version soon!

@dcvz dcvz added this to the 2.0.3 milestone Aug 19, 2021
@dcvz
Copy link
Contributor

dcvz commented Aug 19, 2021

This has now shipped in v2.0.3! 🎉 I will close this now @alexcastillo

@dcvz dcvz closed this as completed Aug 19, 2021
@alexcastillo
Copy link
Author

Thank you, David! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants