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

Error on intiPlaylist and play next #23

Closed
Spiderbezno opened this issue Feb 24, 2017 · 15 comments
Closed

Error on intiPlaylist and play next #23

Spiderbezno opened this issue Feb 24, 2017 · 15 comments

Comments

@Spiderbezno
Copy link

W/System.err: java.lang.IndexOutOfBoundsException: Index: 9, Size: 9
W/System.err: at java.util.ArrayList.get(ArrayList.java:411)
W/System.err: at com.example.jean.jcplayer.JcAudioPlayer.nextAudio(JcAudioPlayer.java:95)
W/System.err: at com.example.jean.jcplayer.JcPlayerView.next(JcPlayerView.java:161)
W/System.err: at com.example.jean.jcplayer.JcPlayerView.onClick(JcPlayerView.java:213)
W/System.err: at android.view.View.performClick(View.java:5637)
W/System.err: at android.view.View$PerformClick.run(View.java:22429)
W/System.err: at android.os.Handler.handleCallback(Handler.java:751)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err: at android.os.Looper.loop(Looper.java:154)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6119)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

@Spiderbezno
Copy link
Author

I add 9 mp3 with this code
for (int i = 0; i < results.size(); i++) {
jcAudios.add(JcAudio.createFromAssets(results.get(i).getTitle(),
results.get(i).getTitle() + ".mp3"));
}
jcPlayerView.initPlaylist(jcAudios);
jcPlayerView.registerInvalidPathListener((MainActivity) getActivity());

@jeancsanchez
Copy link
Owner

@Spiderbezno You must interact with your loop decreasing -1 on size list. In another words, results.size() -1
I think that's it :)

@Spiderbezno
Copy link
Author

But if I do that My last element won't be present in the playlist will it??

@Spiderbezno
Copy link
Author

NOw if i use result.size() -1

java.lang.IndexOutOfBoundsException: Index: 8, Size: 8
02-24 18:58:03.503 3674-3674/ad.aplication.mji.babynanas W/System.err: at java.util.ArrayList.get(ArrayList.java:411)
02-24 18:58:03.503 3674-3674/ad.aplication.mji.babynanas W/System.err: at com.example.jean.jcplayer.JcAudioPlayer.nextAudio(JcAudioPlayer.java:95)
02-24 18:58:03.503 3674-3674/ad.aplication.mji.babynanas W/System.err: at com.example.jean.jcplayer.JcPlayerView.next(JcPlayerView.java:161)
02-24 18:58:03.503 3674-3674/ad.aplication.mji.babynanas W/System.err: at com.example.jean.jcplayer.JcPlayerView.onClick(JcPlayerView.java:213)
02-24 18:58:03.503 3674-3674/ad.aplication.mji.babynanas W/System.err: at android.view.View.performClick(View.java:5637)
02-24 18:58:03.503 3674-3674/ad.aplication.mji.babynanas W/System.err: at android.view.View$PerformClick.run(View.java:22429)
02-24 18:58:03.503 3674-3674/ad.aplication.mji.babynanas W/System.err: at android.os.Handler.handleCallback(Handler.java:751)
02-24 18:58:03.503 3674-3674/ad.aplication.mji.babynanas W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
02-24 18:58:03.504 3674-3674/ad.aplication.mji.babynanas W/System.err: at android.os.Looper.loop(Looper.java:154)
02-24 18:58:03.504 3674-3674/ad.aplication.mji.babynanas W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6119)
02-24 18:58:03.504 3674-3674/ad.aplication.mji.babynanas W/System.err: at java.lang.reflect.Method.invoke(Native Method)
02-24 18:58:03.504 3674-3674/ad.aplication.mji.babynanas W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
02-24 18:58:03.505 3674-3674/ad.aplication.mji.babynanas W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

@Spiderbezno
Copy link
Author

The behaviour strange. I use next button correctly for elements of the array to 0 for 3 but in the next it jump until the las elemnt??

@Spiderbezno
Copy link
Author

and the results.size() -1 I think is not necessary because var i never enter in the loop when the value is 9 because nine is not < 9

@jeancsanchez
Copy link
Owner

jeancsanchez commented Feb 24, 2017

You're right!
Strange. The behavior of the next and previous button is when an IndexOutOfBound is thrown, it is translated like, or the list to arrived the end or is on the first audio.

 public void nextAudio() throws AudioListNullPointerException {
        if(playlist == null || playlist.size() == 0)
            throw new AudioListNullPointerException();

        else {
            if (currentJcAudio != null) {
                try {
                    JcAudio nextJcAudio = playlist.get(currentPositionList + position // 1);
                    this.currentJcAudio = nextJcAudio;
                    jcPlayerService.stop();
                    jcPlayerService.play(nextJcAudio);

                } catch (IndexOutOfBoundsException e) {
                    playAudio(playlist.get(0)); // <-------- List on the end, then jump for the first audio
                    e.printStackTrace();
                }
            }

            updatePositionAudioList();
            playing = true;
            paused = false;
        }
    }

    public void previousAudio() throws AudioListNullPointerException {
        if(playlist == null || playlist.size() == 0)
            throw new AudioListNullPointerException();

        else {
            if (currentJcAudio != null) {
                try {
                    JcAudio previousJcAudio = playlist.get(currentPositionList - position // 1);
                    this.currentJcAudio = previousJcAudio;
                    jcPlayerService.stop();
                    jcPlayerService.play(previousJcAudio);

                } catch (IndexOutOfBoundsException e) {
                    playAudio(playlist.get(0));  // <-------- List is on the first audio, then keep here
                    e.printStackTrace();
                }
            }

            updatePositionAudioList();
            playing = true;
            paused = false;
        }
    }

@jeancsanchez jeancsanchez reopened this Feb 24, 2017
@Spiderbezno
Copy link
Author

This the behaviour always jump to first element, but I can next the first 2 elements before that always appear this error of IndexOutOfBoundsException

@Spiderbezno
Copy link
Author

I do more test if my playlist have more than six elements it produce errors, with six elements o less all ok

@Spiderbezno
Copy link
Author

are there some news??

@Spiderbezno
Copy link
Author

Something new??

@Spiderbezno
Copy link
Author

Is this library stopped?

@Spiderbezno
Copy link
Author

Are the library stopped?

@sajorahasan
Copy link

Any update?

@jeancsanchez
Copy link
Owner

Sorry, I am not working properly on this library these months. This issue continues without a solution for now.

@jeancsanchez jeancsanchez added this to To do in JcPlayer 2.0 Feb 14, 2018
@jeancsanchez jeancsanchez moved this from To do to In progress in JcPlayer 2.0 Feb 15, 2018
JcPlayer 2.0 automation moved this from In progress to Done May 27, 2018
@jeancsanchez jeancsanchez added this to the v2.0.0 milestone May 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
JcPlayer 2.0
  
Done
Development

No branches or pull requests

3 participants