pull/63/head
kunfei 5 years ago
parent 8b0d369a94
commit a4af037e50
  1. 11
      app/src/main/java/io/legado/app/service/AudioPlayService.kt

@ -157,7 +157,6 @@ class AudioPlayService : BaseService(),
}
private fun adjustProgress(position: Int) {
if (isM3U8()) return
if (mediaPlayer.isPlaying) {
mediaPlayer.seekTo(position)
} else {
@ -178,19 +177,13 @@ class AudioPlayService : BaseService(),
}
}
private fun isM3U8(): Boolean {
return url.endsWith("m3u8")
}
/**
* 加载完成
*/
override fun onPrepared(mp: MediaPlayer?) {
if (pause) return
mediaPlayer.start()
if (!isM3U8()) {
mediaPlayer.seekTo(position)
}
postEvent(Bus.AUDIO_SIZE, mediaPlayer.duration)
bookChapter?.let {
it.end = mediaPlayer.duration.toLong()
@ -203,10 +196,10 @@ class AudioPlayService : BaseService(),
* 播放出错
*/
override fun onError(mp: MediaPlayer?, what: Int, extra: Int): Boolean {
if (!mediaPlayer.isPlaying) {
AudioPlay.status = Status.STOP
postEvent(Bus.AUDIO_STATE, Status.STOP)
launch {
toast("error: $what $extra $url")
launch { toast("error: $what $extra $url") }
}
return true
}

Loading…
Cancel
Save