Skip to content

Instantly share code, notes, and snippets.

@mattttvaughn
Created March 23, 2022 22:52
Show Gist options
  • Save mattttvaughn/221767c2613ddc1848ea48b00b9377b6 to your computer and use it in GitHub Desktop.
Save mattttvaughn/221767c2613ddc1848ea48b00b9377b6 to your computer and use it in GitHub Desktop.
...
private val prefsListener = SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
when (key) {
PrefsRepo.KEY_SKIP_SILENCE, PrefsRepo.KEY_PLAYBACK_SPEED -> {
invalidatePlaybackParams()
}
PrefsRepo.KEY_PAUSE_ON_FOCUS_LOST -> {
updateAudioAttrs(exoPlayer)
}
// \/ \/ Add below \/ \/
PrefsRepo.KEY_JUMP_FORWARD_SECONDS, PrefsRepo.KEY_JUMP_BACKWARD_SECONDS -> {
serviceScope.launch {
withContext(Dispatchers.IO) {
sessionToken?.let {
val notification = notificationBuilder.buildNotification(it)
startForeground(NOW_PLAYING_NOTIFICATION, notification)
}
}
}
}
}
}
...
// Just do the same thing you had done to make the notif use current speed icons on each notification build, example below
private fun skipBackwardsAction() = NotificationCompat.Action(
getJumpBackwardIcon(),
context.getString(R.string.skip_backwards),
makePendingIntent(mediaSkipBackwardCode)
)
...
builder.addAction(skipBackwardsAction())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment