[Android] audio: simplify load of a single media

Sébastien Toque git at videolan.org
Sun Feb 10 19:05:32 CET 2013


vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Sun Feb 10 19:00:07 2013 +0100| [d3ddb18877a4953f193608322945d58359cfa639] | committer: Sébastien Toque

audio: simplify load of a single media

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=d3ddb18877a4953f193608322945d58359cfa639
---

 .../src/org/videolan/vlc/AudioServiceController.java       |   12 ++++++++++++
 .../src/org/videolan/vlc/gui/DirectoryViewFragment.java    |   11 ++---------
 vlc-android/src/org/videolan/vlc/gui/MainActivity.java     |    6 +-----
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/AudioServiceController.java b/vlc-android/src/org/videolan/vlc/AudioServiceController.java
index 2dcd826..a79ce0f 100644
--- a/vlc-android/src/org/videolan/vlc/AudioServiceController.java
+++ b/vlc-android/src/org/videolan/vlc/AudioServiceController.java
@@ -213,12 +213,24 @@ public class AudioServiceController implements IAudioPlayerControl {
         load(mediaPathList, position, false, false);
     }
 
+    public void load(String mediaPath, int position, boolean libvlcBacked, boolean noVideo) {
+        ArrayList<String> arrayList = new ArrayList<String>();
+        arrayList.add(mediaPath);
+        load(arrayList, position, libvlcBacked, noVideo);
+    }
+
     public void load(List<String> mediaPathList, int position, boolean libvlcBacked, boolean noVideo) {
         remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "load",
                 new Class<?>[] { List.class, int.class, boolean.class, boolean.class },
                 new Object[] { mediaPathList, position, libvlcBacked, noVideo } );
     }
 
+    public void append(String mediaPath) {
+        ArrayList<String> arrayList = new ArrayList<String>();
+        arrayList.add(mediaPath);
+        append(arrayList);
+    }
+
     public void append(List<String> mediaPathList) {
         remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "append",
                 new Class<?>[] { List.class },
diff --git a/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java b/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
index 7ef59b8..8b63020 100644
--- a/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
@@ -21,7 +21,6 @@
 package org.videolan.vlc.gui;
 
 import java.io.IOException;
-import java.util.ArrayList;
 
 import org.videolan.vlc.AudioServiceController;
 import org.videolan.vlc.LibVLC;
@@ -128,10 +127,7 @@ public class DirectoryViewFragment extends SherlockListFragment implements ISort
             openMediaFile(info.position);
             return true;
         } else if(id == R.id.directory_view_append) {
-            AudioServiceController audioController = AudioServiceController.getInstance();
-            ArrayList<String> tmp = new ArrayList<String>();
-            tmp.add(mediaLocation);
-            audioController.append(tmp);
+            AudioServiceController.getInstance().append(mediaLocation);
             return true;
         } else if(id == R.id.directory_view_delete) {
             AlertDialog alertDialog = CommonDialogs.deleteMedia(getActivity(), mediaLocation,
@@ -143,10 +139,7 @@ public class DirectoryViewFragment extends SherlockListFragment implements ISort
                     });
             alertDialog.show();
         } else if(id == R.id.directory_view_play_audio) {
-            AudioServiceController audioController = AudioServiceController.getInstance();
-            ArrayList<String> arrayList = new ArrayList<String>();
-            arrayList.add(mediaLocation);
-            audioController.load(arrayList, 0, false, true);
+            AudioServiceController.getInstance().load(mediaLocation, 0, false, true);
             AudioPlayerActivity.start(getActivity());
         } else if(id == R.id.directory_view_play_video) {
             VideoPlayerActivity.start(getActivity(), mediaLocation);
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index e52d642..7c0ba9d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -20,8 +20,6 @@
 
 package org.videolan.vlc.gui;
 
-import java.util.ArrayList;
-
 import org.videolan.vlc.AudioService;
 import org.videolan.vlc.AudioServiceController;
 import org.videolan.vlc.LibVLC;
@@ -613,9 +611,7 @@ public class MainActivity extends SherlockFragmentActivity {
                        * (for example, RTSP and TS streaming) where ES can be
                        * dynamically adapted rather than a simple scan.
                        */
-                      ArrayList<String> media = new ArrayList<String>();
-                      media.add(s);
-                      c.append(media);
+                      c.append(s);
                     }
                 };
                 task.execute();



More information about the Android mailing list