Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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),
dataSourceFactory = repository.getDataSourceFactory(item, app),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dataSourceFactory = repository.getDataSourceFactory(item, app),
dataSourceFactory = repository.getDataSourceFactory(item),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A repository will have the ability to access a Context regardless of weather that Context was supplied from the interface call or not. So this should be removed eventually.

)

val uniqueId = Random.nextLong()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package net.newpipe.newplayer.logic
import androidx.annotation.OptIn
import androidx.media3.common.MediaItem
import androidx.media3.common.util.UnstableApi
import androidx.media3.datasource.HttpDataSource
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 +47,7 @@ internal class MediaSourceBuilder
(
private val repository: MediaRepository,
private val mutableErrorFlow: MutableSharedFlow<Exception>,
private val httpDataSourceFactory: HttpDataSource.Factory,
private val dataSourceFactory: DataSource.Factory,
) {
@OptIn(UnstableApi::class)

Expand Down Expand Up @@ -105,10 +105,10 @@ internal suspend fun buildMediaSource(
@OptIn(UnstableApi::class)
private fun toMediaSource(mediaItem: MediaItem, stream: Stream): MediaSource =
if (stream.isDashOrHls)
DashMediaSource.Factory(httpDataSourceFactory)
DashMediaSource.Factory(dataSourceFactory)
.createMediaSource(mediaItem)
else
ProgressiveMediaSource.Factory(httpDataSourceFactory)
ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(mediaItem)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@

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.HttpDataSource
import androidx.media3.datasource.DataSource
import net.newpipe.newplayer.data.Chapter
import net.newpipe.newplayer.data.Stream
import net.newpipe.newplayer.data.Subtitle
Expand Down Expand Up @@ -114,8 +116,9 @@ interface MediaRepository {
/**
* Supply a custom [HttpDataSource.Factory]. This is important for Youtube.
*/
fun getHttpDataSourceFactory(item: String): HttpDataSource.Factory =
DefaultHttpDataSource.Factory()
fun getDataSourceFactory(item: String, context: Context): DataSource.Factory {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fun getDataSourceFactory(item: String, context: Context): DataSource.Factory {
fun getDataSourceFactory(item: String): DataSource.Factory {

return DefaultHttpDataSource.Factory()
}

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