Commit 41043f41 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Widget loads last playlist if service is stopped

parent 0c911397
...@@ -391,6 +391,7 @@ ...@@ -391,6 +391,7 @@
<receiver android:name=".RemoteControlClientReceiver" > <receiver android:name=".RemoteControlClientReceiver" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" /> <action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="org.videolan.vlc.remote.PlayPause" />
</intent-filter> </intent-filter>
</receiver> </receiver>
</application> </application>
......
...@@ -123,6 +123,10 @@ public class RemoteControlClientReceiver extends BroadcastReceiver { ...@@ -123,6 +123,10 @@ public class RemoteControlClientReceiver extends BroadcastReceiver {
abortBroadcast(); abortBroadcast();
if(i != null) if(i != null)
context.sendBroadcast(i); 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);
} }
} }
} }
...@@ -205,7 +205,6 @@ public class AudioService extends Service { ...@@ -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 * 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 * @see http://android-developers.blogspot.fr/2010/06/allowing-applications-to-play-nicer.html
...@@ -267,6 +266,11 @@ public class AudioService extends Service { ...@@ -267,6 +266,11 @@ public class AudioService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
if (intent == null) if (intent == null)
return START_STICKY; return START_STICKY;
if(ACTION_REMOTE_PLAYPAUSE.equals(intent.getAction())){
if (hasCurrentMedia())
return START_STICKY;
else loadLastPlaylist();
}
updateWidget(this); updateWidget(this);
return super.onStartCommand(intent, flags, startId); return super.onStartCommand(intent, flags, startId);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment