The Bug
When I refresh my app by pressing the R key on my console, the already existing tracks are added as duplicates to the TrackPlayer queue.
Steps To Reproduce
This issue does NOT occur if the user closes the app and then opens it back up again. It specifically occurs when the app is refreshed through the console in a development environment. To reproduce the issue you can refresh the app by pressing the R key in your console, and after the app is done refreshing, load your tracks to the queue.
If for example I have 7 tracks in my queue, then refresh the app by pressing the 'r' key on my terminal, my queue will then look like this:
LOG • Existing track with index: 1
LOG • Existing track with index: 2
LOG • Existing track with index: 3
LOG • Existing track with index: 4
LOG • Existing track with index: 5
LOG • Existing track with index: 6
LOG • Existing track with index: 7
LOG • Existing track with index: 8 (duplicate of track with index 1)
LOG • Existing track with index: 9 (duplicate of track with index 2)
LOG • Existing track with index: 10 (duplicate of track with index 3)
LOG • Existing track with index: 11 (duplicate of track with index 4)
LOG • Existing track with index: 12 (duplicate of track with index 5)
LOG • Existing track with index: 13 (duplicate of track with index 6)
LOG • Existing track with index: 14 (duplicate of track with index 7)
The existing articles will then be tripled in the same manner if I refresh the app once more and add yet another track to the queue, and so on.
Environment Info:
The results of npx react-native info:
So it seems that if I reset the TrackPlayer using the reset() method after the app is refreshed and before the tracks are loaded to the player again, then the issue goes away.
The Bug When I refresh my app by pressing the R key on my console, the already existing tracks are added as duplicates to the TrackPlayer queue.
Steps To Reproduce This issue does NOT occur if the user closes the app and then opens it back up again. It specifically occurs when the app is refreshed through the console in a development environment. To reproduce the issue you can refresh the app by pressing the R key in your console, and after the app is done refreshing, load your tracks to the queue.
If for example I have 7 tracks in my queue, then refresh the app by pressing the 'r' key on my terminal, my queue will then look like this:
The existing articles will then be tripled in the same manner if I refresh the app once more and add yet another track to the queue, and so on.
Environment Info: The results of
npx react-native info
:The
react-native-track-player
version I am using:• I am using a real Android device though the issue is probably everywhere • I am running Android version 11 RP1A.200720.011