Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ internalPlayStream(mediaSource: MediaSource, playMode: PlayMode) {
val builder = MediaSourceBuilder(
repository = repository,
mutableErrorFlow = mutableErrorFlow,
httpDataSourceFactory = repository.getHttpDataSourceFactory(item),
httpDataSourceFactory = repository.getHttpDataSourceFactory(item, app),
)

val uniqueId = Random.nextLong()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.annotation.OptIn
import androidx.media3.common.MediaItem
import androidx.media3.common.util.UnstableApi
import androidx.media3.datasource.HttpDataSource
Comment thread
uzu09811 marked this conversation as resolved.
Outdated
import androidx.media3.datasource.DataSource
import androidx.media3.exoplayer.dash.DashMediaSource
import androidx.media3.exoplayer.source.MediaSource
import androidx.media3.exoplayer.source.MergingMediaSource
Expand All @@ -47,7 +48,7 @@ internal class MediaSourceBuilder
(
private val repository: MediaRepository,
private val mutableErrorFlow: MutableSharedFlow<Exception>,
private val httpDataSourceFactory: HttpDataSource.Factory,
private val httpDataSourceFactory: DataSource.Factory,
Comment thread
uzu09811 marked this conversation as resolved.
Outdated
) {
@OptIn(UnstableApi::class)

Expand Down
Comment thread
uzu09811 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@

package net.newpipe.newplayer.repository

import android.os.Build
import android.content.Context
import android.graphics.Bitmap
import androidx.media3.common.MediaMetadata
import androidx.media3.datasource.DefaultHttpDataSource
import androidx.media3.datasource.DataSource
import androidx.media3.datasource.HttpDataSource
import net.newpipe.newplayer.data.Chapter
import net.newpipe.newplayer.data.Stream
import net.newpipe.newplayer.data.Subtitle
import net.newpipe.newplayer.data.StreamTrack
import java.util.concurrent.Executors

/**
* You, dear Developer who uses NewPlayer, will want to implement MediaRepository.
Expand Down Expand Up @@ -114,8 +118,9 @@ interface MediaRepository {
/**
* Supply a custom [HttpDataSource.Factory]. This is important for Youtube.
*/
fun getHttpDataSourceFactory(item: String): HttpDataSource.Factory =
DefaultHttpDataSource.Factory()
fun getHttpDataSourceFactory(item: String, context: Context): DataSource.Factory {
Comment thread
theScrabi marked this conversation as resolved.
Outdated
return DefaultHttpDataSource.Factory()
}

/**
* Get MediaMetadata information for a certain item. Please refer to the media3 documentation
Expand Down