Merge pull request #6578 from Bnyro/master

feat: support for selecting audio codec
This commit is contained in:
Bnyro 2024-10-02 13:08:39 +02:00 committed by GitHub
commit 7dd00512c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 40 additions and 2 deletions

View File

@ -81,6 +81,7 @@ object PreferenceKeys {
const val ALTERNATIVE_PIP_CONTROLS = "alternative_pip_controls"
const val SKIP_SILENCE = "skip_silence"
const val ENABLED_VIDEO_CODECS = "video_codecs"
const val ENABLED_AUDIO_CODECS = "audio_codecs"
const val AUTOPLAY_COUNTDOWN = "autoplay_countdown"
const val LBRY_HLS = "lbry_hls"
const val AUTO_FULLSCREEN_SHORTS = "auto_fullscreen_shorts"

View File

@ -339,6 +339,12 @@ object PlayerHelper {
"all"
)
val enabledAudioCodecs: String
get() = PreferenceHelper.getString(
PreferenceKeys.ENABLED_AUDIO_CODECS,
"all"
)
val playAutomatically: Boolean
get() = PreferenceHelper.getBoolean(
PreferenceKeys.PLAY_AUTOMATICALLY,

View File

@ -17,7 +17,6 @@ import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.os.PowerManager
import android.util.Log
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.PixelCopy
@ -1360,6 +1359,16 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
}
this.setPreferredVideoMimeTypes(*mimeType)
}
val enabledAudioCodecs = PlayerHelper.enabledAudioCodecs
if (enabledAudioCodecs != "all") {
// map the codecs to their corresponding mimetypes
val mimeType = when (enabledAudioCodecs) {
"opus" -> arrayOf("audio/opus")
"mp4" -> arrayOf("audio/mp4a-latm")
else -> throw IllegalArgumentException()
}
this.setPreferredAudioMimeTypes(*mimeType)
}
}
}

View File

@ -424,6 +424,18 @@
<item>avc</item>
</string-array>
<string-array name="audioCodecs">
<item>@string/all</item>
<item>opus</item>
<item>mp4</item>
</string-array>
<string-array name="audioCodecValues">
<item>all</item>
<item>opus</item>
<item>mp4</item>
</string-array>
<string-array name="watchPosition">
<item>@string/always</item>
<item>@string/videos</item>

View File

@ -388,7 +388,8 @@
<string name="skip_silence">Skip silence</string>
<string name="help">Help</string>
<string name="faq">FAQ</string>
<string name="codecs">Codecs</string>
<string name="codecs">Video codecs</string>
<string name="audio_codecs">Audio codecs</string>
<string name="mark_as_watched">Mark as watched</string>
<string name="custom_playback_speed">Custom speed</string>
<string name="custom_playback_speed_summary">Use a different playback speed than for the normal player</string>

View File

@ -113,6 +113,15 @@
app:title="@string/codecs"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:entries="@array/audioCodecs"
android:entryValues="@array/audioCodecValues"
android:icon="@drawable/ic_equalizer"
android:key="audio_codecs"
app:defaultValue="all"
app:title="@string/audio_codecs"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory>
</PreferenceScreen>