catch exceptions thrown at setPlaybackState

This commit is contained in:
tibbi 2018-10-25 19:20:38 +02:00
parent a4f8294f46
commit 9df81953d1

View file

@ -424,9 +424,12 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
}
val playbackState = if (getIsPlaying()) PlaybackStateCompat.STATE_PLAYING else PlaybackStateCompat.STATE_PAUSED
mediaSession!!.setPlaybackState(PlaybackStateCompat.Builder()
.setState(playbackState, PLAYBACK_POSITION_UNKNOWN, 1.0f)
.build())
try {
mediaSession!!.setPlaybackState(PlaybackStateCompat.Builder()
.setState(playbackState, PLAYBACK_POSITION_UNKNOWN, 1.0f)
.build())
} catch (ignored: IllegalStateException) {
}
}
private fun getContentIntent(): PendingIntent {