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

Crashes when closing the App while audio is playing #2

Open
iRahulGaur opened this issue Feb 10, 2020 · 0 comments
Open

Crashes when closing the App while audio is playing #2

iRahulGaur opened this issue Feb 10, 2020 · 0 comments

Comments

@iRahulGaur
Copy link

Steps to reproduce

  1. Play audio
  2. Close App from task menu

Error Log

java.lang.NullPointerException: Attempt to invoke virtual method 'long com.google.android.exoplayer2.SimpleExoPlayer.getContentPosition()' on a null object reference
    at com.thealien.myaudioplayer.player.MediaPlayerAdapter$1.run(MediaPlayerAdapter.java:188)

Fix

//the getDuration method returns a negative one when the audio is stopped
// add this condition at line 188 in MediaPlayerAdapter.java
if (exoPlayer != null && exoPlayer.getContentPosition() >= exoPlayer.getDuration() && exoPlayer.getDuration() > 0) {
    playbackInfoListener.onPlaybackComplete();
}
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

1 participant