Add preference to choose video codecs

This commit is contained in:
Bnyro 2023-02-08 09:41:59 +01:00
parent e9e59fbc1f
commit 8322fbd5c9
7 changed files with 54 additions and 12 deletions

View File

@ -89,6 +89,7 @@ object PreferenceKeys {
const val PAUSE_ON_QUIT = "pause_on_quit"
const val ALTERNATIVE_PIP_CONTROLS = "alternative_pip_controls"
const val SKIP_SILENCE = "skip_silence"
const val ENABLED_VIDEO_CODECS = "video_codecs"
/**
* Background mode

View File

@ -39,7 +39,15 @@ object DashHelper {
val adapSetInfos = ArrayList<AdapSetInfo>()
for (stream in streams.videoStreams!!) {
val enabledVideoCodecs = PlayerHelper.enabledVideoCodecs
// filter the codecs according to the user's preferences
for (stream in streams.videoStreams.filter {
if (enabledVideoCodecs != "all") {
it.codec?.lowercase()?.startsWith(enabledVideoCodecs) ?: true
} else {
true
}
}) {
// ignore dual format streams
if (!stream.videoOnly!!) {
continue
@ -64,7 +72,7 @@ object DashHelper {
)
}
for (stream in streams.audioStreams!!) {
for (stream in streams.audioStreams) {
val adapSetInfo =
adapSetInfos.find {
it.mimeType == stream.mimeType && it.audioTrackId == stream.audioTrackId

View File

@ -279,7 +279,7 @@ object PlayerHelper {
.roundToInt()
.toLong() * 1000
val playbackSpeed: String
private val playbackSpeed: String
get() = PreferenceHelper.getString(
PreferenceKeys.PLAYBACK_SPEED,
"1"
@ -345,6 +345,12 @@ object PlayerHelper {
false
)
val enabledVideoCodecs: String
get() = PreferenceHelper.getString(
PreferenceKeys.ENABLED_VIDEO_CODECS,
"all"
)
fun getDefaultResolution(context: Context): String {
val prefKey = if (NetworkHelper.isNetworkMetered(context)) {
PreferenceKeys.DEFAULT_RESOLUTION_MOBILE

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M10,20h4L14,4h-4v16zM4,20h4v-8L4,12v8zM16,9v11h4L20,9h-4z" />
</vector>

View File

@ -179,15 +179,6 @@
<item>5</item>
</string-array>
<string-array name="videoFormats">
<item>MP4</item>
<item>MKV</item>
</string-array>
<string-array name="videoFormatsValues">
<item>.mp4</item>
<item>.mkv</item>
</string-array>
<string-array name="bufferingGoal">
<item>50s</item>
<item>100s</item>
@ -401,4 +392,16 @@
<item>enabled</item>
</string-array>
<string-array name="videoCodecs">
<item>@string/all</item>
<item>VP9</item>
<item>AVC</item>
</string-array>
<string-array name="videoCodecValues">
<item>all</item>
<item>vp9</item>
<item>avc</item>
</string-array>
</resources>

View File

@ -440,6 +440,7 @@
<string name="skip_silence">Skip silence</string>
<string name="help">Help</string>
<string name="faq">FAQ</string>
<string name="codecs">Codecs</string>
<!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string>

View File

@ -78,4 +78,17 @@
</PreferenceCategory>
<PreferenceCategory app:title="@string/advanced">
<ListPreference
android:entries="@array/videoCodecs"
android:entryValues="@array/videoCodecValues"
android:icon="@drawable/ic_equalizer"
android:key="video_codecs"
app:defaultValue="all"
app:title="@string/codecs"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory>
</PreferenceScreen>