|
|
@ -16,6 +16,7 @@ import androidx.media.AudioFocusRequestCompat |
|
|
|
import com.google.android.exoplayer2.PlaybackException |
|
|
|
import com.google.android.exoplayer2.PlaybackException |
|
|
|
import com.google.android.exoplayer2.Player |
|
|
|
import com.google.android.exoplayer2.Player |
|
|
|
import com.google.android.exoplayer2.SimpleExoPlayer |
|
|
|
import com.google.android.exoplayer2.SimpleExoPlayer |
|
|
|
|
|
|
|
import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource |
|
|
|
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.AppConst |
|
|
|
import io.legado.app.constant.AppConst |
|
|
@ -27,6 +28,7 @@ import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.BookChapter |
|
|
|
import io.legado.app.data.entities.BookChapter |
|
|
|
import io.legado.app.help.ExoPlayerHelper |
|
|
|
import io.legado.app.help.ExoPlayerHelper |
|
|
|
import io.legado.app.help.MediaHelp |
|
|
|
import io.legado.app.help.MediaHelp |
|
|
|
|
|
|
|
import io.legado.app.help.http.okHttpClient |
|
|
|
import io.legado.app.model.AudioPlay |
|
|
|
import io.legado.app.model.AudioPlay |
|
|
|
import io.legado.app.model.ReadAloud |
|
|
|
import io.legado.app.model.ReadAloud |
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeUrl |
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeUrl |
|
|
@ -133,8 +135,10 @@ class AudioPlayService : BaseService(), |
|
|
|
useWebView = true |
|
|
|
useWebView = true |
|
|
|
) |
|
|
|
) |
|
|
|
val uri = Uri.parse(analyzeUrl.url) |
|
|
|
val uri = Uri.parse(analyzeUrl.url) |
|
|
|
|
|
|
|
val dataSourceFactory = OkHttpDataSource.Factory(okHttpClient) |
|
|
|
|
|
|
|
.setDefaultRequestProperties(analyzeUrl.headerMap) |
|
|
|
val mediaSource = ExoPlayerHelper |
|
|
|
val mediaSource = ExoPlayerHelper |
|
|
|
.createMediaSource(uri, userAgent = analyzeUrl.getUserAgent()) |
|
|
|
.createMediaSource(uri, dataSourceFactory) |
|
|
|
exoPlayer.setMediaSource(mediaSource) |
|
|
|
exoPlayer.setMediaSource(mediaSource) |
|
|
|
exoPlayer.playWhenReady = true |
|
|
|
exoPlayer.playWhenReady = true |
|
|
|
exoPlayer.prepare() |
|
|
|
exoPlayer.prepare() |
|
|
|