[Android] Change the aout setting depending on the Android version and VLC major version
Nicolas Pomepuy
git at videolan.org
Fri Nov 18 12:29:45 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Oct 28 12:17:42 2022 +0200| [cd23a83d479d577c0fb872864c1bed364ad0d43b] | committer: Nicolas Pomepuy
Change the aout setting depending on the Android version and VLC major version
> https://code.videolan.org/videolan/vlc-android/commit/cd23a83d479d577c0fb872864c1bed364ad0d43b
---
application/resources/src/main/res/values/arrays.xml | 13 +++++++++++--
.../videolan/television/ui/preferences/PreferencesAudio.kt | 11 ++++++++++-
.../org/videolan/vlc/gui/preferences/PreferencesAudio.kt | 10 +++++++++-
3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/application/resources/src/main/res/values/arrays.xml b/application/resources/src/main/res/values/arrays.xml
index 2b248f3e00..5e5cfe735b 100644
--- a/application/resources/src/main/res/values/arrays.xml
+++ b/application/resources/src/main/res/values/arrays.xml
@@ -374,17 +374,26 @@
<item>album</item>
</string-array>
- <string-array name="aouts">
+ <string-array name="aouts_complete">
<item>@string/aout_aaudio</item>
<item>@string/aout_audiotrack</item>
<item>@string/aout_opensles</item>
</string-array>
- <string-array name="aouts_values" translatable="false">
+ <string-array name="aouts_complete_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
+ <string-array name="aouts">
+ <item>@string/aout_audiotrack</item>
+ <item>@string/aout_opensles</item>
+ </string-array>
+ <string-array name="aouts_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ </string-array>
+
<string-array name="casting_quality">
<item>@string/casting_quality_high</item>
<item>@string/casting_quality_medium</item>
diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt
index 0dc51a01e9..eb09387fc4 100644
--- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt
@@ -29,6 +29,7 @@ import android.os.Bundle
import android.text.InputFilter
import android.text.InputType
import android.util.Log
+import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.preference.CheckBoxPreference
import androidx.preference.EditTextPreference
@@ -47,6 +48,7 @@ import org.videolan.tools.Settings
import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
import org.videolan.vlc.gui.helpers.restartMediaPlayer
+import org.videolan.vlc.isVLC4
import org.videolan.vlc.util.LocaleUtil
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
@@ -74,14 +76,21 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
findPreference<Preference>("enable_headset_detection")?.isVisible = false
findPreference<Preference>("enable_play_on_headset_insertion")?.isVisible = false
findPreference<Preference>("headset_prefs_category")?.isVisible = false
+ val aoutPref = findPreference<ListPreference>("aout")
findPreference<Preference>(RESUME_PLAYBACK)?.isVisible = false
findPreference<Preference>(AUDIO_DUCKING)?.isVisible = !AndroidUtil.isOOrLater
val aout = HWDecoderUtil.getAudioOutputFromDevice()
if (aout != HWDecoderUtil.AudioOutput.ALL) {
/* no AudioOutput choice */
- findPreference<Preference>("aout")?.isVisible = false
+ aoutPref?.isVisible = false
}
+
+ if (isVLC4() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+ aoutPref?.entryValues = activity.resources.getStringArray(R.array.aouts_complete_values)
+ aoutPref?.entries = activity.resources.getStringArray(R.array.aouts_complete)
+ }
+
updatePassThroughSummary()
val opensles = "2" == preferenceManager.sharedPreferences.getString("aout", "0")
if (opensles) findPreference<Preference>("audio_digital_output")?.isVisible = false
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt
index 0727c534cc..ac92744527 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt
@@ -25,6 +25,7 @@ package org.videolan.vlc.gui.preferences
import android.content.Intent
import android.content.SharedPreferences
import android.net.Uri
+import android.os.Build
import android.os.Bundle
import android.text.InputFilter
import android.text.InputType
@@ -48,6 +49,7 @@ import org.videolan.vlc.gui.browser.FilePickerActivity
import org.videolan.vlc.gui.browser.KEY_PICKER_TYPE
import org.videolan.vlc.gui.helpers.UiTools
import org.videolan.vlc.gui.helpers.restartMediaPlayer
+import org.videolan.vlc.isVLC4
import org.videolan.vlc.media.MediaUtils
import org.videolan.vlc.providers.PickerType
import org.videolan.vlc.util.LocaleUtil
@@ -70,11 +72,17 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
super.onCreate(savedInstanceState)
findPreference<Preference>(AUDIO_DUCKING)?.isVisible = !AndroidUtil.isOOrLater
findPreference<Preference>(RESUME_PLAYBACK)?.isVisible = AndroidDevices.isPhone
+ val aoutPref = findPreference<ListPreference>("aout")
val aout = HWDecoderUtil.getAudioOutputFromDevice()
if (aout != HWDecoderUtil.AudioOutput.ALL) {
/* no AudioOutput choice */
- findPreference<Preference>("aout")?.isVisible = false
+ aoutPref?.isVisible = false
}
+ if (isVLC4() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+ aoutPref?.entryValues = requireActivity().resources.getStringArray(R.array.aouts_complete_values)
+ aoutPref?.entries = requireActivity().resources.getStringArray(R.array.aouts_complete)
+ }
+
updatePassThroughSummary()
val opensles = "2" == preferenceManager.sharedPreferences.getString("aout", "0")
if (opensles) findPreference<Preference>("audio_digital_output")?.isVisible = false
More information about the Android
mailing list