优化
This commit is contained in:
@@ -3,6 +3,7 @@ package io.legado.app.model.analyzeRule
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import androidx.annotation.Keep
|
import androidx.annotation.Keep
|
||||||
|
import androidx.media3.common.MediaItem
|
||||||
import cn.hutool.core.util.HexUtil
|
import cn.hutool.core.util.HexUtil
|
||||||
import com.bumptech.glide.load.model.GlideUrl
|
import com.bumptech.glide.load.model.GlideUrl
|
||||||
import com.script.SimpleBindings
|
import com.script.SimpleBindings
|
||||||
@@ -18,6 +19,7 @@ import io.legado.app.exception.ConcurrentException
|
|||||||
import io.legado.app.help.CacheManager
|
import io.legado.app.help.CacheManager
|
||||||
import io.legado.app.help.JsExtensions
|
import io.legado.app.help.JsExtensions
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
|
import io.legado.app.help.exoplayer.ExoPlayerHelper
|
||||||
import io.legado.app.help.glide.GlideHeaders
|
import io.legado.app.help.glide.GlideHeaders
|
||||||
import io.legado.app.help.http.*
|
import io.legado.app.help.http.*
|
||||||
import io.legado.app.help.http.CookieManager.mergeCookies
|
import io.legado.app.help.http.CookieManager.mergeCookies
|
||||||
@@ -629,6 +631,11 @@ class AnalyzeUrl(
|
|||||||
return GlideUrl(url, GlideHeaders(headerMap))
|
return GlideUrl(url, GlideHeaders(headerMap))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getMediaItem(): MediaItem {
|
||||||
|
setCookie()
|
||||||
|
return ExoPlayerHelper.createMediaItem(url, headerMap)
|
||||||
|
}
|
||||||
|
|
||||||
fun getUserAgent(): String {
|
fun getUserAgent(): String {
|
||||||
return headerMap.get(UA_NAME, true) ?: AppConfig.userAgent
|
return headerMap.get(UA_NAME, true) ?: AppConfig.userAgent
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,12 @@ import androidx.media3.common.util.UnstableApi
|
|||||||
import androidx.media3.exoplayer.ExoPlayer
|
import androidx.media3.exoplayer.ExoPlayer
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.base.BaseService
|
import io.legado.app.base.BaseService
|
||||||
import io.legado.app.constant.*
|
import io.legado.app.constant.AppConst
|
||||||
|
import io.legado.app.constant.AppLog
|
||||||
|
import io.legado.app.constant.EventBus
|
||||||
|
import io.legado.app.constant.IntentAction
|
||||||
|
import io.legado.app.constant.NotificationId
|
||||||
|
import io.legado.app.constant.Status
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
import io.legado.app.data.entities.BookChapter
|
import io.legado.app.data.entities.BookChapter
|
||||||
@@ -37,9 +42,17 @@ import io.legado.app.model.analyzeRule.AnalyzeUrl
|
|||||||
import io.legado.app.model.webBook.WebBook
|
import io.legado.app.model.webBook.WebBook
|
||||||
import io.legado.app.receiver.MediaButtonReceiver
|
import io.legado.app.receiver.MediaButtonReceiver
|
||||||
import io.legado.app.ui.book.audio.AudioPlayActivity
|
import io.legado.app.ui.book.audio.AudioPlayActivity
|
||||||
import io.legado.app.utils.*
|
import io.legado.app.utils.activityPendingIntent
|
||||||
import kotlinx.coroutines.*
|
import io.legado.app.utils.broadcastPendingIntent
|
||||||
|
import io.legado.app.utils.postEvent
|
||||||
|
import io.legado.app.utils.printOnDebug
|
||||||
|
import io.legado.app.utils.servicePendingIntent
|
||||||
|
import io.legado.app.utils.toastOnUi
|
||||||
import kotlinx.coroutines.Dispatchers.Main
|
import kotlinx.coroutines.Dispatchers.Main
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.isActive
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
import splitties.systemservices.audioManager
|
import splitties.systemservices.audioManager
|
||||||
import splitties.systemservices.powerManager
|
import splitties.systemservices.powerManager
|
||||||
@@ -193,12 +206,7 @@ class AudioPlayService : BaseService(),
|
|||||||
chapter = AudioPlay.durChapter,
|
chapter = AudioPlay.durChapter,
|
||||||
headerMapF = AudioPlay.headers(true),
|
headerMapF = AudioPlay.headers(true),
|
||||||
)
|
)
|
||||||
exoPlayer.setMediaItem(
|
exoPlayer.setMediaItem(analyzeUrl.getMediaItem())
|
||||||
ExoPlayerHelper.createMediaItem(
|
|
||||||
analyzeUrl.url,
|
|
||||||
analyzeUrl.headerMap
|
|
||||||
)
|
|
||||||
)
|
|
||||||
exoPlayer.playWhenReady = true
|
exoPlayer.playWhenReady = true
|
||||||
exoPlayer.prepare()
|
exoPlayer.prepare()
|
||||||
}.onError {
|
}.onError {
|
||||||
|
|||||||
Reference in New Issue
Block a user