From e31ee031cb74b60d99d3fd1f2e1327e961c03f0d Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 19 Jun 2023 20:53:38 -0400 Subject: [PATCH] Removes the cache from streaming files to make sure the stream keeps playing. --- .../com/vitorpamplona/amethyst/ui/components/VideoView.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/VideoView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/VideoView.kt index b86268d9f..c408f29f5 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/VideoView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/VideoView.kt @@ -52,11 +52,14 @@ import com.google.android.exoplayer2.C import com.google.android.exoplayer2.ExoPlayer import com.google.android.exoplayer2.MediaItem import com.google.android.exoplayer2.Player +import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource import com.google.android.exoplayer2.source.ProgressiveMediaSource import com.google.android.exoplayer2.source.hls.HlsMediaSource import com.google.android.exoplayer2.ui.AspectRatioFrameLayout import com.google.android.exoplayer2.ui.StyledPlayerView +import com.google.android.exoplayer2.upstream.DataSource import com.vitorpamplona.amethyst.VideoCache +import com.vitorpamplona.amethyst.service.HttpClient import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -144,8 +147,10 @@ fun VideoView( if (videoUri.startsWith("file")) { setMediaItem(media) } else if (videoUri.endsWith("m3u8")) { + // Should not use cache. + val dataSourceFactory: DataSource.Factory = OkHttpDataSource.Factory(HttpClient.getHttpClient()) setMediaSource( - HlsMediaSource.Factory(VideoCache.get()).createMediaSource( + HlsMediaSource.Factory(dataSourceFactory).createMediaSource( media ) )