React-native-track-player: Removes one or more tracks from the queue

Created on 24 Apr 2020  Â·  20Comments  Â·  Source: react-native-kit/react-native-track-player

Describe the bug
It doesn't anything.
[email protected]

To Reproduce
Steps to reproduce the behavior:

  1. Select the Track Object
  2. Trying to remove the current Tracks
  3. Add the new Tracks object

Environment (please complete the following information):

System:
    OS: macOS 10.15.2
    CPU: (4) x64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
    Memory: 60.51 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.4.0 - /usr/local/bin/node
    Yarn: 1.22.4 - ~/.yarn/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 23, 24, 25, 26, 27, 28
      Build Tools: 23.0.1, 23.0.3, 25.0.0, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.2, 28.0.3
  IDEs:
    Android Studio: 3.6 AI-192.7142.36.36.6392135
    Xcode: 11.3/11C29 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.13.1 => 16.13.1 
    react-native: 0.61.5 => 0.61.5 
  npmGlobalPackages:
    react-native-clean-project: 3.2.4
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7

*Code - EDITED *

let arrayTracksIds = []
const tracksEmFila = await TrackPlayer.getQueue();

for (let i in tracksEmFila) {
            arrayTracksIds.push({
                id: tracksEmFila[i].id,
                url: tracksEmFila[i].assetUrl96
            });
        }
await TrackPlayer.remove(arrayTracksIds);

Bug Needs Confirmation

All 20 comments

Would you have time to test trying the same thing within the example app on ‘dev’? (1.2.x)

@curiousdustin, sure. I'll do that

Also which platform(s)?

Android, for now

The example app is making its normal ritual... downloading this, download that ... gradle build whatever ... Meanwhile, how can I clear the queue without using reset()?

I think you just need to pass an array of string IDs instead of objects.

The docs may need improvement on this method.

I did it in first place but crash my app. When I tried passing an object just did nothing ...

I’m on mobile right now but I’m pretty sure it should be just string IDs.

Can you provide the error for the crash?

That's the hard thing... My app just close.

By the way, when I tried run the example app, i got this error:

Loading dependency graph...(node:68361) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision:
  Duplicate module name: react-native
  Paths: /Users/celiogarcia/dev/lolo/example/node_modules/react-native/package.json collides with /Users/celiogarcia/dev/lolo/example/node_modules/react-native-track-player/example/node_modules/react-native/package.json

This error is caused by `hasteImpl` returning the same name for different files.

For that error try removing the example node modules and installing again.

You can use android studio logcat, or logcat in a terminal, to see the crash error.

Okay... It's now 02:43 am. I so tired. I'll look for it late. Thanks for your support sor far

Removing the example folder inside on node_modules/react-native-track-player fix it.
I tested the same thing on example app and works

My approach was wrong thats why when I passed an array of ids crashed my app. After testing on example app I realized how bad I was doing it.
Thats all fine. I'll closed this issue.

Thanks. ;)

@curiousdustin , I have to reopen this issue because its still crash the app. I used the same code on my project that I used on example app.
The logcat tell me that:


2020-04-24 13:48:22.834 10103-10103/com.toquemedia.toqueplay E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.toquemedia.toqueplay, PID: 10103
    java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
        at java.util.ArrayList.get(ArrayList.java:437)
        at java.util.Collections$SynchronizedList.get(Collections.java:2461)
        at com.guichaguri.trackplayer.service.player.ExoPlayback.onPositionDiscontinuity(ExoPlayback.java:271)
        at com.guichaguri.trackplayer.service.player.ExoPlayback.onTimelineChanged(ExoPlayback.java:262)
        at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.lambda$run$0$ExoPlayerImpl$PlaybackInfoUpdate(ExoPlayerImpl.java:790)
        at com.google.android.exoplayer2.-$$Lambda$ExoPlayerImpl$PlaybackInfoUpdate$N_S5kRfhaRTAkH28P5luFgKnFjQ.invokeListener(Unknown Source:2)
        at com.google.android.exoplayer2.BasePlayer$ListenerHolder.invoke(BasePlayer.java:165)
        at com.google.android.exoplayer2.ExoPlayerImpl.invokeAll(ExoPlayerImpl.java:823)
        at com.google.android.exoplayer2.ExoPlayerImpl.access$000(ExoPlayerImpl.java:43)
        at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.run(ExoPlayerImpl.java:787)
        at com.google.android.exoplayer2.ExoPlayerImpl.notifyListeners(ExoPlayerImpl.java:726)
        at com.google.android.exoplayer2.ExoPlayerImpl.updatePlaybackInfo(ExoPlayerImpl.java:701)
        at com.google.android.exoplayer2.ExoPlayerImpl.handlePlaybackInfo(ExoPlayerImpl.java:648)
        at com.google.android.exoplayer2.ExoPlayerImpl.handleEvent(ExoPlayerImpl.java:598)
        at com.google.android.exoplayer2.ExoPlayerImpl$1.handleMessage(ExoPlayerImpl.java:126)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6815)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

You are using the same version in the example and in your app?

You are saying the same basic process works in the example app, but not in yours?

Are you able to crash the example app with similar code?

I'm using RNTrackPlayer 2.0.0-rc13 with RN 0.61.5 and same basic process works in the example app. For now, I'm using TrackPlayer.removeUpcomingTracks() and working as I expected when used TrackPlayer.remove()

Are you also testing in the example from the same version: 2.0.0-rc13?

Does your last statement means you are using both of these in order, and it does not crash anymore?

TrackPlayer.removeUpcomingTracks()
TrackPlayer.remove([id1, id2, id3])

Noup. My last statement is:

await TrackPlayer.removeUpcomingTracks()
await TrackPlayer.add(newTracks);

The IndexOutOfBoundsException error you mentioned is #661, which is fixed by #778, which has not been included in a v2 release yet.

Was this page helpful?
0 / 5 - 0 ratings