优化
This commit is contained in:
@@ -163,31 +163,32 @@ class AudioPlayService : BaseService(),
|
|||||||
private fun play() {
|
private fun play() {
|
||||||
if (useWakeLock) wakeLock.acquire(10 * 60 * 1000L /*10 minutes*/)
|
if (useWakeLock) wakeLock.acquire(10 * 60 * 1000L /*10 minutes*/)
|
||||||
upNotification()
|
upNotification()
|
||||||
if (requestFocus()) {
|
if (!requestFocus()) {
|
||||||
execute(context = Main) {
|
return
|
||||||
AudioPlay.status = Status.STOP
|
}
|
||||||
postEvent(EventBus.AUDIO_STATE, Status.STOP)
|
execute(context = Main) {
|
||||||
upPlayProgressJob?.cancel()
|
AudioPlay.status = Status.STOP
|
||||||
val analyzeUrl = AnalyzeUrl(
|
postEvent(EventBus.AUDIO_STATE, Status.STOP)
|
||||||
url,
|
upPlayProgressJob?.cancel()
|
||||||
source = AudioPlay.bookSource,
|
val analyzeUrl = AnalyzeUrl(
|
||||||
ruleData = AudioPlay.book,
|
url,
|
||||||
chapter = AudioPlay.durChapter,
|
source = AudioPlay.bookSource,
|
||||||
headerMapF = AudioPlay.headers(true),
|
ruleData = AudioPlay.book,
|
||||||
|
chapter = AudioPlay.durChapter,
|
||||||
|
headerMapF = AudioPlay.headers(true),
|
||||||
|
)
|
||||||
|
exoPlayer.setMediaItem(
|
||||||
|
ExoPlayerHelper.createMediaItem(
|
||||||
|
analyzeUrl.url,
|
||||||
|
analyzeUrl.headerMap
|
||||||
)
|
)
|
||||||
exoPlayer.setMediaItem(
|
)
|
||||||
ExoPlayerHelper.createMediaItem(
|
exoPlayer.playWhenReady = true
|
||||||
analyzeUrl.url,
|
exoPlayer.prepare()
|
||||||
analyzeUrl.headerMap
|
}.onError {
|
||||||
)
|
AppLog.put("播放出错\n${it.localizedMessage}", it)
|
||||||
)
|
toastOnUi("$url ${it.localizedMessage}")
|
||||||
exoPlayer.playWhenReady = true
|
stopSelf()
|
||||||
exoPlayer.prepare()
|
|
||||||
}.onError {
|
|
||||||
AppLog.put("播放出错\n${it.localizedMessage}", it)
|
|
||||||
toastOnUi("$url ${it.localizedMessage}")
|
|
||||||
stopSelf()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user