Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
uzu09811 authored Nov 6, 2024
1 parent 88baa44 commit de9fb0d
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package net.newpipe.newplayer.repository

import android.os.Build
import android.content.Context
import android.net.http.HttpEngine
import android.graphics.Bitmap
import androidx.media3.common.MediaMetadata
Expand Down Expand Up @@ -122,13 +123,16 @@ interface MediaRepository {
/**
* Supply a custom [HttpDataSource.Factory]. This is important for Youtube.
*/
fun getHttpDataSourceFactory(item: String, context): DataSource.Factory {
fun getHttpDataSourceFactory(item: String, context: Context): DataSource.Factory {
// return best dataSourceFactory based on the available best dataSoures
if (Build.VERSION.SDK_INT >= 34) {
return HttpEngineDataSource.Factory(HttpEngine.Builder(context).build(), Executors.newSingleThreadExecutor())
} else {
if (!CronetProvider.getAllProviders(context).filter { it.isEnabled }.toList().isEmpty()) {
return CronetDataSource.Factory(CronetEngine.Builder(context).enableHttpCache(CronetEngine.Builder.HTTP_CACHE_IN_MEMORY, 10 * 1024 * 1024).build(), Executors.newSingleThreadExecutor())
val cronetEngine = CronetEngine.Builder(context)
.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_IN_MEMORY, 10 * 1024 * 1024)
.build()
return CronetDataSource.Factory(cronetEngine, Executors.newSingleThreadExecutor())
} else {
return DefaultHttpDataSource.Factory()
}
Expand Down Expand Up @@ -181,4 +185,4 @@ interface MediaRepository {
* [https://www.youtube.com/watch?v=H8ZH_mkfPUY&t=19s](https://www.youtube.com/watch?v=H8ZH_mkfPUY&t=19s)
*/
suspend fun getTimestampLink(item: String, timestampInSeconds: Long): String
}
}

0 comments on commit de9fb0d

Please sign in to comment.