Voice Broadcast Player - Add missing try catch

This commit is contained in:
Florian Renaud 2022-10-18 00:37:38 +02:00
parent 402224721b
commit 4a32ccecfa
1 changed files with 8 additions and 1 deletions

View File

@ -120,7 +120,14 @@ class VoiceBroadcastPlayer @Inject constructor(
}
private suspend fun prepareMediaPlayer(messageAudioContent: MessageAudioContent): MediaPlayer {
val audioFile = session.fileService().downloadFile(messageAudioContent)
// Download can fail
val audioFile = try {
session.fileService().downloadFile(messageAudioContent)
} catch (failure: Throwable) {
Timber.e(failure, "Unable to start playback")
throw VoiceFailure.UnableToPlay(failure)
}
return audioFile.inputStream().use { fis ->
MediaPlayer().apply {
setAudioAttributes(