Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't make a new load() without doing reset() first #1

Closed
jasongrishkoff opened this issue Apr 2, 2017 · 3 comments
Closed

Can't make a new load() without doing reset() first #1

jasongrishkoff opened this issue Apr 2, 2017 · 3 comments
Labels

Comments

@jasongrishkoff
Copy link

Let's say I'm already playing a song with load(), but I want to move to the next song or change to a completely different playlist. It seems that calling load() again (with new details) results in the following:

04-02 09:52:36.574  4357  4425 E unknown:React: Exception in native call
04-02 09:52:36.574  4357  4425 E unknown:React: java.lang.IllegalStateException
04-02 09:52:36.574  4357  4425 E unknown:React:         at android.media.MediaPlayer.nativeSetDataSource(Native Method)
04-02 09:52:36.574  4357  4425 E unknown:React:         at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1078)
04-02 09:52:36.574  4357  4425 E unknown:React:         at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1067)
04-02 09:52:36.574  4357  4425 E unknown:React:         at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1009)
04-02 09:52:36.574  4357  4425 E unknown:React:         at android.media.MediaPlayer.setDataSource(MediaPlayer.java:967)
04-02 09:52:36.574  4357  4425 E unknown:React:         at guichaguri.trackplayer.player.players.AndroidPlayer.load(AndroidPlayer.java:83)
04-02 09:52:36.574  4357  4425 E unknown:React:         at guichaguri.trackplayer.logic.components.MediaWrapper.load(MediaWrapper.java:62)
04-02 09:52:36.574  4357  4425 E unknown:React:         at guichaguri.trackplayer.TrackModule.load(TrackModule.java:155)
04-02 09:52:36.574  4357  4425 E unknown:React:         at java.lang.reflect.Method.invoke(Native Method)
04-02 09:52:36.574  4357  4425 E unknown:React:         at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:345)
04-02 09:52:36.574  4357  4425 E unknown:React:         at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:136)
04-02 09:52:36.574  4357  4425 E unknown:React:         at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
04-02 09:52:36.574  4357  4425 E unknown:React:         at android.os.Handler.handleCallback(Handler.java:751)
04-02 09:52:36.574  4357  4425 E unknown:React:         at android.os.Handler.dispatchMessage(Handler.java:95)
04-02 09:52:36.574  4357  4425 E unknown:React:         at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
04-02 09:52:36.574  4357  4425 E unknown:React:         at android.os.Looper.loop(Looper.java:154)
04-02 09:52:36.574  4357  4425 E unknown:React:         at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
04-02 09:52:36.574  4357  4425 E unknown:React:         at java.lang.Thread.run(Thread.java:761)

However, if I do TrackPlayer.reset() before calling TrackPlayer.load(), it works fine.

This "hack" creates another problem though, because TrackPlayer.reset() also triggers "ended," so if you're using "skipNext" and "ended" to both fire a "nextSong()", it gets stuck in an infinite loop.

@Guichaguri Guichaguri added the Bug label Apr 2, 2017
@Guichaguri
Copy link
Collaborator

Related to #2
I'll make sure it doesn't trigger "ended" when loading/skipping songs in the queue

@jasongrishkoff
Copy link
Author

Cool, I think same should apply if creating a new playlist as well? Say I've created a playlist based on a deadmau5 song (which is how Indie Shuffle works), but suddenly I see a new Alt-J song and want to generate a playlist based on that, will need to switch / load a new queue then. Right now I use mobx to manage my playlist, and do two things:

  1. Slice the current playlist using current position so that users can still go to previous songs;
  2. Do a playlist.concat(newSongs) so that the new playlist exists going forward.
    Let me know if that doesn't make sense :)

@Guichaguri
Copy link
Collaborator

Yes, that will be possible. You will be able to remove([id1, id2, id3]) from the queue and add({...}) new songs.

mahmoudfelfel pushed a commit to mahmoudfelfel/react-native-track-player that referenced this issue Oct 5, 2018
mahmoudfelfel pushed a commit to mahmoudfelfel/react-native-track-player that referenced this issue Oct 5, 2018
mahmoudfelfel pushed a commit to mahmoudfelfel/react-native-track-player that referenced this issue Oct 5, 2018
chochihim pushed a commit to chochihim/react-native-track-player that referenced this issue Oct 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants