[Android] Apply Chromecast options to LibVLC
Geoffrey Métais
git at videolan.org
Tue Jan 23 18:31:09 CET 2018
vlc-android | branch: chromecast | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan 23 10:51:43 2018 +0100| [7e8506d0f60e0f79245cfad69c742f7ab229632e] | committer: Geoffrey Métais
Apply Chromecast options to LibVLC
> https://code.videolan.org/videolan/vlc-android/commit/7e8506d0f60e0f79245cfad69c742f7ab229632e
---
.../vlc/gui/preferences/PreferencesCasting.kt | 19 ++++++++++++++++++-
vlc-android/src/org/videolan/vlc/util/VLCOptions.java | 15 ++++++---------
2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesCasting.kt b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesCasting.kt
index 2137dbced..2d15c34cf 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesCasting.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesCasting.kt
@@ -22,11 +22,28 @@
*/
package org.videolan.vlc.gui.preferences
+import android.content.SharedPreferences
+import android.os.Bundle
import org.videolan.vlc.R
+import org.videolan.vlc.util.VLCInstance
-class PreferencesCasting : BasePreferenceFragment() {
+class PreferencesCasting : BasePreferenceFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
override fun getTitleId() = R.string.casting_category
override fun getXml() = R.xml.preferences_casting
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
+ }
+
+ override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
+ when (key) {
+ "casting_passthrough", "casting_quality" -> {
+ VLCInstance.restart()
+ (activity as? PreferencesActivity)?.restartMediaPlayer()
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/util/VLCOptions.java b/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
index 1438e9efc..e10677ad7 100644
--- a/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
+++ b/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
@@ -31,10 +31,9 @@ import org.videolan.libvlc.MediaPlayer;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.libvlc.util.HWDecoderUtil;
import org.videolan.libvlc.util.VLCUtil;
+import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.R;
-import org.videolan.vlc.RendererDelegate;
import org.videolan.vlc.VLCApplication;
-import org.videolan.medialibrary.media.MediaWrapper;
import java.io.File;
import java.util.ArrayList;
@@ -126,7 +125,11 @@ public class VLCOptions {
options.add("--keystore-file");
options.add(new File(context.getDir("keystore", Context.MODE_PRIVATE), "file").getAbsolutePath());
+ //Chromecast
options.add(verboseMode ? "-vv" : "-v");
+ if (pref.getBoolean("casting_passthrough", true)) options.add("--sout-chromecast-audio-passthrough");
+ else options.add("--no-sout-chromecast-audio-passthrough");
+ options.add("--sout-chromecast-conversion-quality="+pref.getString("casting_quality", "2"));
return options;
}
@@ -181,10 +184,10 @@ public class VLCOptions {
boolean noVideo = (flags & MediaWrapper.MEDIA_VIDEO) == 0;
final boolean paused = (flags & MediaWrapper.MEDIA_PAUSED) != 0;
int hardwareAcceleration = HW_ACCELERATION_DISABLED;
+ final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
if (!noHardwareAcceleration) {
try {
- final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
hardwareAcceleration = Integer.parseInt(pref.getString("hardware_acceleration", "-1"));
} catch (NumberFormatException ignored) {}
}
@@ -200,12 +203,6 @@ public class VLCOptions {
if (noVideo) media.addOption(":no-video");
if (paused) media.addOption(":start-paused");
-
- if (RendererDelegate.INSTANCE.getSelectedRenderer() != null) {
- final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
- media.addOption(":sout-chromecast-audio-passthrough="+pref.getBoolean("casting_passthrough", true));
- media.addOption(":sout-chromecast-conversion-quality="+pref.getString("casting_quality", "2"));
- }
}
private static MediaPlayer.Equalizer getEqualizerSetFromSettings(SharedPreferences pref) {
More information about the Android
mailing list