anilbeesetti / nextplayer

An Android native video player
GNU General Public License v3.0
1.28k stars 59 forks source link

Implemented advanced settings screen (buffering and HTTP settings) #928

Open bitlinker opened 2 months ago

bitlinker commented 2 months ago

Hi! Please take a look at this implementation of additional network settings screen. It allows to configure ExoPlayer's streaming buffers size and to add aditional parameters to HTTP requests: User-Agent and other header values (some streaming hosts require specific values)

Also please note the fixes at PlayerViewModel:46 and PlayerViewModel:52. The settings repo is "preheated" here, but it seems not enough: When the player is created PlayerActivity.kt:288, the settings are not available yet and default ones are used! I know that runBlocking() is ugly, but can't find better solution here. It shouldn't actually block the thread since the preferences flow should already have value available.

anilbeesetti commented 2 months ago

Hey @bitlinker can you fix linting by running the following cmd in terminal ./gradlew ktlintFormat

bitlinker commented 2 months ago

Hey @bitlinker can you fix linting by running the following cmd in terminal ./gradlew ktlintFormat

Done

anilbeesetti commented 2 months ago

Hey @bitlinker, thanks for the pull request. I couldn't play local videos now. I believe it's because we're setting DefaultHttpDataSource as the default data source for ExoPlayer. We should only set the DefaultHttpDataSource if the URI is a network URI. And I think we should rename network settings screen to advanced settings screen, What do you think?

bitlinker commented 2 months ago

Hey @bitlinker, thanks for the pull request. I couldn't play local videos now. I believe it's because we're setting DefaultHttpDataSource as the default data source for ExoPlayer. We should only set the DefaultHttpDataSource if the URI is a network URI. And I think we should rename network settings screen to advanced settings screen, What do you think?

Hey @anilbeesetti, sorry I didn't checked the local videos last time. Yes, the issue was with the data source configuration - the DefaultDataSource.Factory is responsible for selecting required data sources based on URI scheme, but DefaultHttpDataSource.Factory was used instead. It is working now for both local and network streams.

I agree, advanced settings is more suitable name here, since buffer configurations are applied to local videos too. Renamed it.

bitlinker commented 2 months ago

Fixed ktlint =)