[Android] Widget loads last playlist if service is stopped

Geoffrey Métais git at videolan.org
Wed Oct 15 11:09:47 CEST 2014


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Oct 14 18:38:12 2014 +0200| [41043f41e6eaaf5741532d640d3271246a248da5] | committer: Geoffrey Métais

Widget loads last playlist if service is stopped

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

 vlc-android/AndroidManifest.xml                                  |    1 +
 .../src/org/videolan/vlc/RemoteControlClientReceiver.java        |    4 ++++
 vlc-android/src/org/videolan/vlc/audio/AudioService.java         |    6 +++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/vlc-android/AndroidManifest.xml b/vlc-android/AndroidManifest.xml
index da51abb..350180c 100644
--- a/vlc-android/AndroidManifest.xml
+++ b/vlc-android/AndroidManifest.xml
@@ -391,6 +391,7 @@
         <receiver android:name=".RemoteControlClientReceiver" >
             <intent-filter>
                 <action android:name="android.intent.action.MEDIA_BUTTON" />
+                <action android:name="org.videolan.vlc.remote.PlayPause" />
             </intent-filter>
         </receiver>
     </application>
diff --git a/vlc-android/src/org/videolan/vlc/RemoteControlClientReceiver.java b/vlc-android/src/org/videolan/vlc/RemoteControlClientReceiver.java
index 6c389ca..fe43fd9 100644
--- a/vlc-android/src/org/videolan/vlc/RemoteControlClientReceiver.java
+++ b/vlc-android/src/org/videolan/vlc/RemoteControlClientReceiver.java
@@ -123,6 +123,10 @@ public class RemoteControlClientReceiver extends BroadcastReceiver {
                 abortBroadcast();
             if(i != null)
                 context.sendBroadcast(i);
+        } else if (action.equals(AudioService.ACTION_REMOTE_PLAYPAUSE)){
+            intent = new Intent(context, AudioService.class);
+            intent.setAction(AudioService.ACTION_REMOTE_PLAYPAUSE);
+            context.startService(intent);
         }
     }
 }
diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
index 6da9fc0..b57ae96 100644
--- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
@@ -205,7 +205,6 @@ public class AudioService extends Service {
         }
     }
 
-
     /**
      * Set up the remote control and tell the system we want to be the default receiver for the MEDIA buttons
      * @see http://android-developers.blogspot.fr/2010/06/allowing-applications-to-play-nicer.html
@@ -267,6 +266,11 @@ public class AudioService extends Service {
     public int onStartCommand(Intent intent, int flags, int startId) {
         if (intent == null)
             return START_STICKY;
+        if(ACTION_REMOTE_PLAYPAUSE.equals(intent.getAction())){
+            if (hasCurrentMedia())
+                return START_STICKY;
+            else loadLastPlaylist();
+        }
         updateWidget(this);
         return super.onStartCommand(intent, flags, startId);
     }



More information about the Android mailing list