优化
This commit is contained in:
@@ -3,6 +3,7 @@ package io.legado.app.model
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import io.legado.app.R
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.constant.EventBus
|
import io.legado.app.constant.EventBus
|
||||||
import io.legado.app.constant.IntentAction
|
import io.legado.app.constant.IntentAction
|
||||||
@@ -182,7 +183,7 @@ object AudioPlay : CoroutineScope by MainScope() {
|
|||||||
val book = book ?: return
|
val book = book ?: return
|
||||||
durChapter = appDb.bookChapterDao.getChapter(book.bookUrl, durChapterIndex)
|
durChapter = appDb.bookChapterDao.getChapter(book.bookUrl, durChapterIndex)
|
||||||
durAudioSize = durChapter?.end?.toInt() ?: 0
|
durAudioSize = durChapter?.end?.toInt() ?: 0
|
||||||
postEvent(EventBus.AUDIO_SUB_TITLE, durChapter?.title ?: "")
|
postEvent(EventBus.AUDIO_SUB_TITLE, durChapter?.title ?: appCtx.getString(R.string.data_loading))
|
||||||
postEvent(EventBus.AUDIO_SIZE, durAudioSize)
|
postEvent(EventBus.AUDIO_SIZE, durAudioSize)
|
||||||
postEvent(EventBus.AUDIO_PROGRESS, durChapterPos)
|
postEvent(EventBus.AUDIO_PROGRESS, durChapterPos)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -423,6 +423,7 @@ class AudioPlayService : BaseService(),
|
|||||||
AudioPlay.playPositionChanged(exoPlayer.currentPosition.toInt())
|
AudioPlay.playPositionChanged(exoPlayer.currentPosition.toInt())
|
||||||
postEvent(EventBus.AUDIO_BUFFER_PROGRESS, exoPlayer.bufferedPosition.toInt())
|
postEvent(EventBus.AUDIO_BUFFER_PROGRESS, exoPlayer.bufferedPosition.toInt())
|
||||||
postEvent(EventBus.AUDIO_PROGRESS, AudioPlay.durChapterPos)
|
postEvent(EventBus.AUDIO_PROGRESS, AudioPlay.durChapterPos)
|
||||||
|
postEvent(EventBus.AUDIO_SIZE, exoPlayer.duration.toInt())
|
||||||
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING)
|
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING)
|
||||||
delay(1000)
|
delay(1000)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user