Simplify logic of AlarmService.playSound

This probably won't fix the disabling sound bug.
This commit is contained in:
Brandon Presley 2023-11-13 14:12:25 +13:00
parent 79e462efc2
commit d0c0a52ab4
1 changed files with 3 additions and 2 deletions

View File

@ -57,11 +57,12 @@ class AlarmService : Service(), OnPreparedListener {
}
private fun playSound(settings: Settings) {
if (settings.sound == null && !settings.noSound) {
if (settings.noSound) return;
if (settings.sound == null) {
mediaPlayer = MediaPlayer.create(applicationContext, R.raw.argon)
mediaPlayer?.start()
mediaPlayer?.setOnCompletionListener { vibrator?.cancel() }
} else if (settings.sound != null && !settings.noSound) {
} else {
mediaPlayer = MediaPlayer().apply {
setAudioAttributes(
AudioAttributes.Builder()