Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CronetEngine and HttpEngine support #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
uzu09811 marked this conversation as resolved.
Show resolved Hide resolved
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,
uzu09811 marked this conversation as resolved.
Show resolved Hide resolved
) {
@OptIn(UnstableApi::class)

Expand Down
uzu09811 marked this conversation as resolved.
Show resolved Hide 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 {
Copy link
Member

Choose a reason for hiding this comment

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

Is an Android Context now really needed? If so, some doc should be added to explain why that's the case.

Copy link
Author

Choose a reason for hiding this comment

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

@AudricV
Yes an Android Context is needed when building CronetDataSource, OkhttpDataSource or HttpEngineDataSource

return DefaultHttpDataSource.Factory()
}

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