[Android] [PATCH 3/3] Open by default with AudioService

Thomas Guillem thomas at gllm.fr
Thu Apr 9 17:45:50 CEST 2015


---
 vlc-android/src/org/videolan/vlc/util/Util.java | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index 7a297a1..f1571e7 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -36,6 +36,8 @@ import org.videolan.vlc.MediaWrapper;
 import org.videolan.vlc.MediaLibrary;
 import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
+import org.videolan.vlc.VLCCallbackTask;
+import org.videolan.vlc.audio.AudioServiceController;
 import org.videolan.vlc.gui.video.VideoPlayerActivity;
 
 import android.annotation.TargetApi;
@@ -210,7 +212,21 @@ public class Util {
     }
 
     public static void openStream(Context context, final String uri){
-        VideoPlayerActivity.start(context, uri);
+        VLCCallbackTask task = new VLCCallbackTask(context){
+            @Override
+            public void run() {
+                AudioServiceController c = AudioServiceController.getInstance();
+
+                      /* Use the audio player by default. If a video track is
+                       * detected, then it will automatically switch to the video
+                       * player. This allows us to support more types of streams
+                       * (for example, RTSP and TS streaming) where ES can be
+                       * dynamically adapted rather than a simple scan.
+                       */
+                c.load(uri, false);
+            }
+        };
+        task.execute();
     }
 
     private static String getMediaString(Context ctx, int id) {
-- 
2.1.3



More information about the Android mailing list