pull/46/head
kunfei 5 years ago
parent f032adabc5
commit 8594d63264
  1. 8
      app/src/main/java/io/legado/app/service/AudioPlayService.kt

@ -25,6 +25,8 @@ import io.legado.app.help.MediaHelp
import io.legado.app.receiver.MediaButtonReceiver
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.utils.postEvent
import kotlinx.coroutines.launch
import org.jetbrains.anko.toast
class AudioPlayService : BaseService(),
@ -99,10 +101,16 @@ class AudioPlayService : BaseService(),
private fun play(url: String) {
if (requestFocus()) {
try {
postEvent(Bus.AUDIO_STATE, Status.PLAY)
mediaPlayer.reset()
mediaPlayer.setDataSource(url)
mediaPlayer.prepareAsync()
} catch (e: Exception) {
launch {
toast(e.localizedMessage + " " + url)
}
}
}
}

Loading…
Cancel
Save