[Android] [PATCH] startService for remote MEDIA_PLAY command

Jean-Baptiste Kempf jb at videolan.org
Thu Dec 11 15:58:08 CET 2014


LGTM.

On 11 Dec, Geoffrey Métais wrote :
> This will wake up VLC when controlled from remote controller.
> Like Bluetooth a2dp device/remote contoller or smartwatches
> ---
>  .../src/org/videolan/vlc/RemoteControlClientReceiver.java        | 9 +++++----
>  vlc-android/src/org/videolan/vlc/audio/AudioService.java         | 8 +++++++-
>  2 files changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/vlc-android/src/org/videolan/vlc/RemoteControlClientReceiver.java b/vlc-android/src/org/videolan/vlc/RemoteControlClientReceiver.java
> index fe43fd9..b493cc6 100644
> --- a/vlc-android/src/org/videolan/vlc/RemoteControlClientReceiver.java
> +++ b/vlc-android/src/org/videolan/vlc/RemoteControlClientReceiver.java
> @@ -75,8 +75,7 @@ public class RemoteControlClientReceiver extends BroadcastReceiver {
>                  case KeyEvent.KEYCODE_HEADSETHOOK:
>                  case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
>                      long time = SystemClock.uptimeMillis();
> -                    switch (event.getAction())
> -                    {
> +                    switch (event.getAction()) {
>                          case KeyEvent.ACTION_DOWN:
>                              if (event.getRepeatCount() > 0)
>                                  break;
> @@ -103,8 +102,10 @@ public class RemoteControlClientReceiver extends BroadcastReceiver {
>                      }
>                      break;
>                  case KeyEvent.KEYCODE_MEDIA_PLAY:
> -                    i = new Intent(AudioService.ACTION_REMOTE_PLAY);
> -                    break;
> +                    i = new Intent(context, AudioService.class);
> +                    i.setAction(AudioService.ACTION_REMOTE_PLAY);
> +                    context.startService(i);
> +                    return;
>                  case KeyEvent.KEYCODE_MEDIA_PAUSE:
>                      i = new Intent(AudioService.ACTION_REMOTE_PAUSE);
>                      break;
> diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
> index 6fc79a0..b81526d 100644
> --- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java
> +++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
> @@ -277,7 +277,13 @@ public class AudioService extends Service {
>          if(ACTION_REMOTE_PLAYPAUSE.equals(intent.getAction())){
>              if (hasCurrentMedia())
>                  return START_STICKY;
> -            else loadLastPlaylist();
> +            else
> +                loadLastPlaylist();
> +        } else if (ACTION_REMOTE_PLAY.equals(intent.getAction())) {
> +            if (hasCurrentMedia())
> +                play();
> +            else
> +                loadLastPlaylist();
>          }
>          updateWidget(this);
>          return super.onStartCommand(intent, flags, startId);
> -- 
> 1.9.1
> 
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android

-- 
With my kindest regards,

-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device


More information about the Android mailing list