[Android] [PATCH 2/2] Add open MRL feature in menu

Edward Wang edward.c.wang at compdigitec.com
Sun Mar 11 05:43:54 CET 2012


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

diff --git a/vlc-android/res/menu/media_library.xml b/vlc-android/res/menu/media_library.xml
index 06c0166..729f843 100644
--- a/vlc-android/res/menu/media_library.xml
+++ b/vlc-android/res/menu/media_library.xml
@@ -25,4 +25,8 @@
         android:id="@+id/ml_menu_refresh"
         android:icon="@drawable/ic_menu_refresh"
         android:title="@string/refresh" />
+    <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 541132b..28c78d3 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -78,4 +78,5 @@
     <string name="track_video_info">Codec: %1$s\nResolution: %2$dx%3$d</string>
     <string name="track_text">Subtitles track</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/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);
     }
-- 
1.7.5.4



More information about the Android mailing list