React-native-track-player: Pause doesn't work in "PLAYBACK_TRACK_CHANGED" event

Created on 28 Apr 2020  路  7Comments  路  Source: react-native-kit/react-native-track-player

Describe the bug
When I try to pause the player with TrackPlayer.pause() when the track is changed, it doesn't pause. The "nextTrack" continues to play even though pause was called.

To Reproduce
In service.js add TrackPlayer.pause() in the event listener:

TrackPlayer.addEventListener(TrackPlayer.TrackPlayerEvents.PLAYBACK_TRACK_CHANGED, async ({ track, nextTrack, position }) => {
    await TrackPlayer.pause();
}

Environment (please complete the following information):

System:
    OS: macOS 10.15.3
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 647.02 MB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 13.1.0 - /usr/local/bin/node
    Yarn: 1.19.2 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5977832
    Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.12.0 => 16.12.0 
    react-native: 0.61.5 => 0.61.5 
  npmGlobalPackages:
    react-native-cli: 2.0.1

What react-native-track-player version are you using?

"react-native-track-player": "^1.2.3",

Are you testing on a real device or in the simulator? Which OS version are you running?
iOS - iPad 6th generation and Simulator

Bug Needs Confirmation iOS

All 7 comments

@zacharywenner , have you tested on Android? Just wondering if this behaves the same.

I haven't tested in Android yet, but I plan on it soon. I'll update here if I find anything. Thanks.

On iOS I think this happens because of _playWhenReady in swiftaudio. I will look into overriding the pause method.

My brief testing indicates this is not an issue on Android.

Thank you so much!

馃憤 Let us know if you find any strange side effects.

Fix released in 1.2.4

Was this page helpful?
0 / 5 - 0 ratings