add option to limit hls

This commit is contained in:
Bnyro 2022-09-26 19:12:52 +02:00
parent c3b2f5baee
commit b18bf98854
4 changed files with 20 additions and 2 deletions

View File

@ -77,6 +77,7 @@ object PreferenceKeys {
const val PICTURE_IN_PICTURE = "picture_in_picture" const val PICTURE_IN_PICTURE = "picture_in_picture"
const val PLAYER_RESIZE_MODE = "player_resize_mode" const val PLAYER_RESIZE_MODE = "player_resize_mode"
const val SB_SKIP_MANUALLY = "sb_skip_manually_key" const val SB_SKIP_MANUALLY = "sb_skip_manually_key"
const val LIMIT_HLS = "limit_hls"
/** /**
* Background mode * Background mode
@ -101,8 +102,6 @@ object PreferenceKeys {
const val CLEAR_WATCH_HISTORY = "clear_watch_history" const val CLEAR_WATCH_HISTORY = "clear_watch_history"
const val CLEAR_WATCH_POSITIONS = "clear_watch_positions" const val CLEAR_WATCH_POSITIONS = "clear_watch_positions"
const val SHARE_WITH_TIME_CODE = "share_with_time_code" const val SHARE_WITH_TIME_CODE = "share_with_time_code"
const val BACKUP_SETTINGS = "backup_settings"
const val RESTORE_SETTINGS = "restore_settings"
/** /**
* History * History

View File

@ -1358,6 +1358,18 @@ class PlayerFragment : BaseFragment() {
// control for the track sources like subtitles and audio source // control for the track sources like subtitles and audio source
trackSelector = DefaultTrackSelector(requireContext()) trackSelector = DefaultTrackSelector(requireContext())
// limit hls to full hd
if (
PreferenceHelper.getBoolean(
PreferenceKeys.LIMIT_HLS,
false
)
) {
val newParams = trackSelector.buildUponParameters()
.setMaxVideoSize(1920, 1080)
trackSelector.setParameters(newParams)
}
exoPlayer = ExoPlayer.Builder(requireContext()) exoPlayer = ExoPlayer.Builder(requireContext())
.setMediaSourceFactory(DefaultMediaSourceFactory(dataSourceFactory)) .setMediaSourceFactory(DefaultMediaSourceFactory(dataSourceFactory))
.setLoadControl(loadControl) .setLoadControl(loadControl)

View File

@ -333,6 +333,7 @@
<string name="navigation_bar">Navigation bar</string> <string name="navigation_bar">Navigation bar</string>
<string name="select_at_least_one">Please select at least one item</string> <string name="select_at_least_one">Please select at least one item</string>
<string name="change_region">Trending seems to be unavailable for the current region. Please select another in the settings.</string> <string name="change_region">Trending seems to be unavailable for the current region. Please select another in the settings.</string>
<string name="limit_hls">Limit HLS to 1080p</string>
<!-- Notification channel strings --> <!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string> <string name="download_channel_name">Download Service</string>

View File

@ -66,6 +66,12 @@
app:title="@string/playerAudioFormat" app:title="@string/playerAudioFormat"
app:useSimpleSummaryProvider="true" /> app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:icon="@drawable/ic_play_filled"
android:title="@string/limit_hls"
app:key="limit_hls" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory app:title="@string/background_mode"> <PreferenceCategory app:title="@string/background_mode">