catch exceptions thrown at setting up mediaplayer

This commit is contained in:
tibbi 2018-09-14 14:02:26 +02:00
parent d8c9b34cc5
commit 2dba635e2f

View File

@ -146,13 +146,17 @@ class ReminderActivity : SimpleActivity() {
}
val soundUri = Uri.parse(if (alarm != null) alarm!!.soundUri else config.timerSoundUri)
mediaPlayer = MediaPlayer().apply {
setAudioStreamType(AudioManager.STREAM_ALARM)
setDataSource(this@ReminderActivity, soundUri)
setVolume(lastVolumeValue, lastVolumeValue)
isLooping = true
prepare()
start()
try {
mediaPlayer = MediaPlayer().apply {
setAudioStreamType(AudioManager.STREAM_ALARM)
setDataSource(this@ReminderActivity, soundUri)
setVolume(lastVolumeValue, lastVolumeValue)
isLooping = true
prepare()
start()
}
} catch (e: Exception) {
showErrorToast(e)
}
if (config.increaseVolumeGradually) {