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

notification does not show when expected #10

Open
fullmers opened this issue Feb 2, 2018 · 2 comments
Open

notification does not show when expected #10

fullmers opened this issue Feb 2, 2018 · 2 comments

Comments

@fullmers
Copy link

fullmers commented Feb 2, 2018

Instead, the notification shows up after you have paused it, presumably because showNotification() is placed in onPlayerStateChanged().

Then the notification disappears after completing a question. It will only reappear after pressing pause again in the next question. This behaviour probably occurs because the activity is finished and recreated with each next question.

Not sure where showNotification() should be placed instead to address these issues.

@fullmers fullmers changed the title notification does not show when the music starts playing notification does not show when expected Feb 2, 2018
@ghost
Copy link

ghost commented May 12, 2018

Did you find a fix for this? I can't seem to see notification when playing or paused .

Keep Coding : - )

@gshadows
Copy link

I call showMediaNotification() after mMediaSession.setPlaybackState() inside initMediaSession() to fix this.

But this is not the only problem with notifications. Notification re-appears after cancelled when returning to main activity, because mNotificationManager.cancelAll() must be called AFTER stopPlayer() completes. Otherwise we cancel notification, then call player.stop and this causes state change along with new notification.

Additionally, I had to call initMediaSession() from within initializePlayer() jsut BEFORE mPlayer.addListener() because sometimes callback was called when no mMediaSession or mStateBuilder was created causing crash.

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

2 participants