react-native-track-player icon indicating copy to clipboard operation
react-native-track-player copied to clipboard

PlaybackTrackChanged does not fire immediately on Android (unlike iOS)

Open taylorakin17 opened this issue 3 years ago • 2 comments

Describe the Bug When a track ends on Android, the playbackTrackChanged event does not fire immediately every time (which is inconsistent with how iOS functions, playbackTrackChanged fires immediately every time in my testing). The context within which we discovered this (and when it becomes the most evident) is having a Trackplayer.pause() in the listener for Event.PlaybackTrackChanged. The next two sections have more detail for how to reproduce.

Steps To Reproduce

  1. Once you have the example app set up, put Trackplayer.pause() in Track player listener for Event.PlaybackTrackChanged.
  2. Play a few tracks and observe that the next track begins before it gets paused many times.

Code To Reproduce

 TrackPlayer.addEventListener(
    Event.PlaybackTrackChanged,
    async ({ track, nextTrack, position }) => {
       await Trackplayer.pause();
  }
)

Environment Info: This happens both on Simulators and on actual devices. We are currently testing on RNTP 2.2.0 rc4, but the problem also occurs in RNTP v1.

System:
    OS: macOS 12.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 735.60 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 18.5.0 - /usr/local/bin/node
    Yarn: 3.2.1 - /usr/local/bin/yarn
    npm: 8.12.1 - /usr/local/bin/npm
    Watchman: 2022.07.04.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /Users/taylorakin/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK:
      API Levels: 29, 30, 31
      Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0
      System Images: android-30 | Google APIs Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8609683
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.2 - /usr/bin/javac
    Python: 3.8.8 - /Users/taylorakin/opt/anaconda3/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.3 => 0.63.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

taylorakin17 avatar Jul 26 '22 19:07 taylorakin17

Repro fork https://github.com/taylorakin17/react-native-track-player-example/commit/adfdca60d644c9b720d29c795116393fa0316228

jspizziri avatar Jul 27 '22 13:07 jspizziri

See discord thread for more background https://discord.com/channels/567636850513018880/600714011318681610/1001622976770351246

jspizziri avatar Jul 27 '22 13:07 jspizziri

Verified that this is not occurring in https://github.com/doublesymmetry/react-native-track-player/pull/1713 – the tracks immediately pause when pressing the. next button.

puckey avatar Oct 07 '22 13:10 puckey

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jan 06 '23 02:01 github-actions[bot]

Closed by https://github.com/doublesymmetry/react-native-track-player/pull/1713

jspizziri avatar Jan 24 '23 16:01 jspizziri