mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
Merge pull request #2995 from Bnyro/master
Add preference to choose video codecs
This commit is contained in:
commit
b2c17392d8
@ -89,6 +89,7 @@ object PreferenceKeys {
|
|||||||
const val PAUSE_ON_QUIT = "pause_on_quit"
|
const val PAUSE_ON_QUIT = "pause_on_quit"
|
||||||
const val ALTERNATIVE_PIP_CONTROLS = "alternative_pip_controls"
|
const val ALTERNATIVE_PIP_CONTROLS = "alternative_pip_controls"
|
||||||
const val SKIP_SILENCE = "skip_silence"
|
const val SKIP_SILENCE = "skip_silence"
|
||||||
|
const val ENABLED_VIDEO_CODECS = "video_codecs"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Background mode
|
* Background mode
|
||||||
|
@ -39,7 +39,15 @@ object DashHelper {
|
|||||||
|
|
||||||
val adapSetInfos = ArrayList<AdapSetInfo>()
|
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
|
// ignore dual format streams
|
||||||
if (!stream.videoOnly!!) {
|
if (!stream.videoOnly!!) {
|
||||||
continue
|
continue
|
||||||
@ -64,7 +72,7 @@ object DashHelper {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (stream in streams.audioStreams!!) {
|
for (stream in streams.audioStreams) {
|
||||||
val adapSetInfo =
|
val adapSetInfo =
|
||||||
adapSetInfos.find {
|
adapSetInfos.find {
|
||||||
it.mimeType == stream.mimeType && it.audioTrackId == stream.audioTrackId
|
it.mimeType == stream.mimeType && it.audioTrackId == stream.audioTrackId
|
||||||
|
@ -279,7 +279,7 @@ object PlayerHelper {
|
|||||||
.roundToInt()
|
.roundToInt()
|
||||||
.toLong() * 1000
|
.toLong() * 1000
|
||||||
|
|
||||||
val playbackSpeed: String
|
private val playbackSpeed: String
|
||||||
get() = PreferenceHelper.getString(
|
get() = PreferenceHelper.getString(
|
||||||
PreferenceKeys.PLAYBACK_SPEED,
|
PreferenceKeys.PLAYBACK_SPEED,
|
||||||
"1"
|
"1"
|
||||||
@ -345,6 +345,12 @@ object PlayerHelper {
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val enabledVideoCodecs: String
|
||||||
|
get() = PreferenceHelper.getString(
|
||||||
|
PreferenceKeys.ENABLED_VIDEO_CODECS,
|
||||||
|
"all"
|
||||||
|
)
|
||||||
|
|
||||||
fun getDefaultResolution(context: Context): String {
|
fun getDefaultResolution(context: Context): String {
|
||||||
val prefKey = if (NetworkHelper.isNetworkMetered(context)) {
|
val prefKey = if (NetworkHelper.isNetworkMetered(context)) {
|
||||||
PreferenceKeys.DEFAULT_RESOLUTION_MOBILE
|
PreferenceKeys.DEFAULT_RESOLUTION_MOBILE
|
||||||
|
10
app/src/main/res/drawable/ic_equalizer.xml
Normal file
10
app/src/main/res/drawable/ic_equalizer.xml
Normal 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>
|
@ -179,15 +179,6 @@
|
|||||||
<item>5</item>
|
<item>5</item>
|
||||||
</string-array>
|
</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">
|
<string-array name="bufferingGoal">
|
||||||
<item>50s</item>
|
<item>50s</item>
|
||||||
<item>100s</item>
|
<item>100s</item>
|
||||||
@ -401,4 +392,16 @@
|
|||||||
<item>enabled</item>
|
<item>enabled</item>
|
||||||
</string-array>
|
</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>
|
</resources>
|
||||||
|
@ -440,6 +440,7 @@
|
|||||||
<string name="skip_silence">Skip silence</string>
|
<string name="skip_silence">Skip silence</string>
|
||||||
<string name="help">Help</string>
|
<string name="help">Help</string>
|
||||||
<string name="faq">FAQ</string>
|
<string name="faq">FAQ</string>
|
||||||
|
<string name="codecs">Codecs</string>
|
||||||
|
|
||||||
<!-- Notification channel strings -->
|
<!-- Notification channel strings -->
|
||||||
<string name="download_channel_name">Download Service</string>
|
<string name="download_channel_name">Download Service</string>
|
||||||
|
@ -78,4 +78,17 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</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>
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user