[Android] Add open MRL feature in menu

Edward Wang git at videolan.org
Sun Apr 15 19:50:10 CEST 2012


android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sun Apr 15 19:40:38 2012 +0200| [092dcc27c525014d295af2513b3f2dfc9a2df0c0] | committer: Jean-Baptiste Kempf

Add open MRL feature in menu

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=092dcc27c525014d295af2513b3f2dfc9a2df0c0
---

 vlc-android/res/menu/media_library.xml             |    5 +++-
 vlc-android/res/values/strings.xml                 |    1 +
 vlc-android/src/org/videolan/vlc/AudioService.java |    5 +++
 .../src/org/videolan/vlc/gui/MainActivity.java     |   27 ++++++++++++++++++++
 4 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/vlc-android/res/menu/media_library.xml b/vlc-android/res/menu/media_library.xml
index 00f3daf..6296da3 100644
--- a/vlc-android/res/menu/media_library.xml
+++ b/vlc-android/res/menu/media_library.xml
@@ -25,6 +25,9 @@
         android:id="@+id/ml_menu_about"
         android:icon="@android:drawable/ic_menu_info_details"
         android:title="@string/about" />
-
+    <item
+        android:id="@+id/ml_menu_open_mrl"
+        android:icon="@android:drawable/ic_btn_speak_now"
+        android:title="@string/open_mrl" />
 
 </menu>
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index ac7c2f1..48083cc 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -80,4 +80,5 @@
     <string name="track_text">Subtitles track</string>
     <string name="track_text_info">Codec: %1$s\nLanguage: %2$s</string>
     <string name="track_unknown">Unknown track</string>
+    <string name="open_mrl">Open MRL</string>
 </resources>
diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index bac9e7f..af5cfc1 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -463,6 +463,7 @@ public class AudioService extends Service {
         @Override
         public void load(List<String> mediaPathList, int position)
                 throws RemoteException {
+            Log.v(TAG, "Loading position " + ((Integer)position).toString() + " in " + mediaPathList.toString());
             mEventManager.addHandler(mEventHandler);
             mMediaList.clear();
             mPrevious.clear();
@@ -470,6 +471,10 @@ public class AudioService extends Service {
             for (int i = 0; i < mediaPathList.size(); i++) {
                 String path = mediaPathList.get(i);
                 Media media = db.getMedia(AudioService.this, path);
+                if(media == null) {
+                    Log.v(TAG, "Creating on-the-fly Media object for " + path);
+                    media = new Media(AudioService.this, path, false);
+                }
                 mMediaList.add(media);
             }
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 2660948..3868d41 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -20,6 +20,8 @@
 
 package org.videolan.vlc.gui;
 
+import java.util.ArrayList;
+
 import org.videolan.vlc.AudioServiceController;
 import org.videolan.vlc.LibVLC;
 import org.videolan.vlc.MediaLibrary;
@@ -33,10 +35,12 @@ import org.videolan.vlc.widget.AudioMiniPlayer;
 
 import android.app.Activity;
 import android.app.ActivityGroup;
+import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.TabActivity;
 import android.content.BroadcastReceiver;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.SharedPreferences;
@@ -53,6 +57,7 @@ import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.Button;
 import android.widget.CheckBox;
+import android.widget.EditText;
 import android.widget.ImageButton;
 import android.widget.ProgressBar;
 import android.widget.TabHost;
@@ -232,6 +237,28 @@ public class MainActivity extends TabActivity {
             case R.id.ml_menu_refresh:
                 MediaLibrary.getInstance(this).loadMediaItems(this);
                 break;
+            case R.id.ml_menu_open_mrl:
+                AlertDialog.Builder b = new AlertDialog.Builder(this);
+                final EditText input = new EditText(this);
+                b.setTitle("Resource MRL");
+                b.setMessage("Enter MRL (media resource locator): e.g. rtsp:// or http://");
+                b.setView(input);
+                b.setPositiveButton("Open", new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int button) {
+                        AudioServiceController c = AudioServiceController.getInstance();
+                        ArrayList<String> media = new ArrayList<String>();
+                        media.add(input.getText().toString());
+                        c.append(media);
+                        }
+                    }
+                );
+                b.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface arg0, int arg1) {
+                        return;
+                        }});
+                b.show();
+                break;
         }
         return super.onOptionsItemSelected(item);
     }



More information about the Android mailing list