doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.25k stars 1k forks source link

Doesn't work correctly queue and getActiveTrackIndex() on iOS #2238

Closed topovik closed 5 months ago

topovik commented 8 months ago

Describe the Bug When you add a track to the top of the queue, the index of the active track is not updated and because of this the queue does not work correctly

Code To Reproduce

*Step1*
const track1= {...fields };
await TrackPlayer.add(track1)
console.log(await TrackPlayer.getQueue())// length - 1
const currentActiveIndex = await TrackPlayer.getActiveTrackIndex(); // 0

*Step2*
const track2= {...fields };
await TrackPlayer.add(track2, 0)
console.log(await TrackPlayer.getQueue())// length - 2 (new track in top)
const currentActiveIndex = await TrackPlayer.getActiveTrackIndex(); // 0 (should be 1)

*Step3*
const track3= {...fields };
await TrackPlayer.add(track3, 0)
console.log(await TrackPlayer.getQueue())// length - 3 (new track in top)
const currentActiveIndex = await TrackPlayer.getActiveTrackIndex(); // 1 (should be 2)

Environment Info: Paste the results of npx react-native info

System:
    OS: Linux 6.5 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 22.79 GB / 31.26 GB
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    Yarn: Not Found
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
    Watchman: 20220828.225657.0 - /usr/local/bin/watchman
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: 11.0.21 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.14 => 0.71.14 
  npmGlobalPackages:
    *react-native*: Not Found
info React Native v0.73.2 is now available (your project is running on v0.71.14).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.73.2
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.71.14
info For more info, check out "https://reactnative.dev/docs/upgrading".

Paste the exact react-native-track-player version you are using

"react-native-track-player": "^4.0.0-rc09"
"react-native-track-player": "^4.0.1-nightly-47b2d08033563ef4d7e76a7f061c244ac3dba1ec"

Real device? Or simulator?

Real device - iPhone 11 Pro Max

What OS are you running?

iOS 17.2.1

How I can Help Do you have any thoughts on this kind of work?

P.S. On Android work correct

github-actions[bot] commented 5 months ago

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] commented 5 months ago

This issue was closed because it has been stalled for 7 days with no activity.