[Android] Audio service: add functions to return data about the next and previous media to play

Adrien Maglo git at videolan.org
Tue Jan 14 10:10:31 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Tue Jan 14 10:09:10 2014 +0100| [7ab6919f810b1266f5e395a9c1fe70d06d49c0ad] | committer: Adrien Maglo

Audio service: add functions to return data about the next and previous media to play

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

 vlc-android/src/org/videolan/vlc/AudioService.java |   48 ++++++++++++++++++++
 .../org/videolan/vlc/AudioServiceController.java   |   30 ++++++++++++
 .../vlc/interfaces/IAudioPlayerControl.java        |   12 +++++
 .../org/videolan/vlc/interfaces/IAudioService.aidl |    6 +++
 4 files changed, 96 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index 780f28c..0759f93 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -919,6 +919,22 @@ public class AudioService extends Service {
         }
 
         @Override
+        public String getArtistPrev() throws RemoteException {
+            if (mPrevIndex != -1)
+                return mLibVLC.getMediaList().getMedia(mPrevIndex).getArtist();
+            else
+                return null;
+        }
+
+        @Override
+        public String getArtistNext() throws RemoteException {
+            if (mNextIndex != -1)
+                return mLibVLC.getMediaList().getMedia(mNextIndex).getArtist();
+            else
+                return null;
+        }
+
+        @Override
         public String getTitle() throws RemoteException {
             if (hasCurrentMedia())
                 return getCurrentMedia().getTitle();
@@ -927,6 +943,22 @@ public class AudioService extends Service {
         }
 
         @Override
+        public String getTitlePrev() throws RemoteException {
+            if (mPrevIndex != -1)
+                return mLibVLC.getMediaList().getMedia(mPrevIndex).getTitle();
+            else
+                return null;
+        }
+
+        @Override
+        public String getTitleNext() throws RemoteException {
+            if (mNextIndex != -1)
+                return mLibVLC.getMediaList().getMedia(mNextIndex).getTitle();
+            else
+                return null;
+        }
+
+        @Override
         public Bitmap getCover() {
             if (hasCurrentMedia()) {
                 return AudioService.this.getCover();
@@ -935,6 +967,22 @@ public class AudioService extends Service {
         }
 
         @Override
+        public Bitmap getCoverPrev() throws RemoteException {
+            if (mPrevIndex != -1)
+                return AudioUtil.getCover(AudioService.this, mLibVLC.getMediaList().getMedia(mPrevIndex), 64);
+            else
+                return null;
+        }
+
+        @Override
+        public Bitmap getCoverNext() throws RemoteException {
+            if (mNextIndex != -1)
+                return AudioUtil.getCover(AudioService.this, mLibVLC.getMediaList().getMedia(mNextIndex), 64);
+            else
+                return null;
+        }
+
+        @Override
         public synchronized void addAudioCallback(IAudioServiceCallback cb)
                 throws RemoteException {
             Integer count = mCallback.get(cb);
diff --git a/vlc-android/src/org/videolan/vlc/AudioServiceController.java b/vlc-android/src/org/videolan/vlc/AudioServiceController.java
index 27f23e7..fd0349e 100644
--- a/vlc-android/src/org/videolan/vlc/AudioServiceController.java
+++ b/vlc-android/src/org/videolan/vlc/AudioServiceController.java
@@ -289,11 +289,31 @@ public class AudioServiceController implements IAudioPlayerControl {
     }
 
     @Override
+    public String getArtistPrev() {
+        return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getArtistPrev", null, null);
+    }
+
+    @Override
+    public String getArtistNext() {
+        return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getArtistNext", null, null);
+    }
+
+    @Override
     public String getTitle() {
         return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getTitle", null, null);
     }
 
     @Override
+    public String getTitlePrev() {
+        return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getTitlePrev", null, null);
+    }
+
+    @Override
+    public String getTitleNext() {
+        return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getTitleNext", null, null);
+    }
+
+    @Override
     public boolean isPlaying() {
         return hasMedia() && remoteProcedureCall(mAudioServiceBinder, boolean.class, false, "isPlaying", null, null);
     }
@@ -331,6 +351,16 @@ public class AudioServiceController implements IAudioPlayerControl {
     }
 
     @Override
+    public Bitmap getCoverPrev() {
+        return remoteProcedureCall(mAudioServiceBinder, Bitmap.class, (Bitmap)null, "getCoverPrev", null, null);
+    }
+
+    @Override
+    public Bitmap getCoverNext() {
+        return remoteProcedureCall(mAudioServiceBinder, Bitmap.class, (Bitmap)null, "getCoverNext", null, null);
+    }
+
+    @Override
     public void next() {
         remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "next", null, null);
     }
diff --git a/vlc-android/src/org/videolan/vlc/interfaces/IAudioPlayerControl.java b/vlc-android/src/org/videolan/vlc/interfaces/IAudioPlayerControl.java
index e4dae8a..0492e0b 100644
--- a/vlc-android/src/org/videolan/vlc/interfaces/IAudioPlayerControl.java
+++ b/vlc-android/src/org/videolan/vlc/interfaces/IAudioPlayerControl.java
@@ -27,12 +27,24 @@ import android.graphics.Bitmap;
 public interface IAudioPlayerControl {
     String getTitle();
 
+    String getTitlePrev();
+
+    String getTitleNext();
+
     String getArtist();
 
+    String getArtistPrev();
+
+    String getArtistNext();
+
     String getAlbum();
 
     Bitmap getCover();
 
+    Bitmap getCoverPrev();
+
+    Bitmap getCoverNext();
+
     int getLength();
 
     int getTime();
diff --git a/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl b/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl
index da0b76b..5600048 100644
--- a/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl
+++ b/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl
@@ -41,11 +41,17 @@ interface IAudioService {
     boolean hasNext();
     boolean hasPrevious();
     String getTitle();
+    String getTitlePrev();
+    String getTitleNext();
     String getArtist();
+    String getArtistPrev();
+    String getArtistNext();
     String getAlbum();
     int getTime();
     int getLength();
     Bitmap getCover();
+    Bitmap getCoverPrev();
+    Bitmap getCoverNext();
     void addAudioCallback(IAudioServiceCallback cb);
     void removeAudioCallback(IAudioServiceCallback cb);
     void detectHeadset(boolean enable);



More information about the Android mailing list