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

Crash when playback is started immediately after binding #32

Open
flavioarfaria opened this issue Aug 9, 2014 · 5 comments
Open

Crash when playback is started immediately after binding #32

flavioarfaria opened this issue Aug 9, 2014 · 5 comments

Comments

@flavioarfaria
Copy link

This piece of code makes the app crash:

@Override
public void onResume() {
    super.onResume();
    mPlayerHater = PlayerHater.bind(getActivity());
    mPlayerHater.play(new MySong());
}

On the other hand, this piece of code works:

new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            startPlaybackIfNeeded();
        }
    }, 1000);

It seems like the player takes some time to start. No stacktrace is provided when the crash happens.

@djahmednawaz
Copy link

Facing same problem. Thanks for sharing. You solved my Problem. 😄

@cqr
Copy link
Owner

cqr commented Sep 30, 2015

I'll take a look at this when I get a chance. I think it may require one tick but I thought I covered this

@danvass
Copy link

danvass commented Oct 7, 2015

This also makes it crash with an IllegalStateException.

    @Override
    public void onDestroy() {
        super.onDestroy();
        mPlayerHater.release();
    }

@rafaeltoledo
Copy link

Try to call it before super.onDestroy(). Super callbacks for destroy reasons must be called at end of method

@danvass
Copy link

danvass commented Oct 7, 2015

@rafaeltoledo That's how I originally did it but it didn't make a difference. I ended up adding the runnable snippet posted above and it seems to work or rather it doesn't crash. I'm not actually sure whether it does release because if there is only one song queued up then the audio player won't disappear and it can't close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants