[vlc-devel] [PATCH] [Android] Implement Scrobbling compatibility (#11904)

Tristan Matthews tmatth at videolan.org
Wed Apr 8 22:25:51 CEST 2015


On Wed, Apr 8, 2015 at 4:19 PM, Guillaume <h.guillaume at gmail.com> wrote:
> Forgot to attach the actual patch:
>
> ---
>  .../src/org/videolan/vlc/audio/AudioService.java   | 27
> ++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>
> diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java

Nice patch, note that vlc-android patches/discussion should normally happen on:
https://mailman.videolan.org/listinfo/android

Best,
Tristan

> b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
> index 090ef6f..f99334d 100644
> --- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java
> +++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
> @@ -819,6 +819,7 @@ public class AudioService extends Service {
>          mHandler.removeMessages(SHOW_PROGRESS);
>          // hideNotification(); <-- see event handler
>          mLibVLC.pause();
> +        broadcastMetadata(this);
>      }
>
>      private void play() {
> @@ -828,6 +829,7 @@ public class AudioService extends Service {
>              mHandler.sendEmptyMessage(SHOW_PROGRESS);
>              showNotification();
>              updateWidget(this);
> +            broadcastMetadata(this);
>          }
>      }
>
> @@ -840,6 +842,7 @@ public class AudioService extends Service {
>          mPrevious.clear();
>          mHandler.removeMessages(SHOW_PROGRESS);
>          hideNotification();
> +        broadcastMetadata(this);
>          executeUpdate();
>          executeUpdateProgress();
>          changeAudioFocus(false);
> @@ -928,6 +931,7 @@ public class AudioService extends Service {
>          setUpRemoteControlClient();
>          showNotification();
>          updateWidget(this);
> +        broadcastMetadata(this);
>          updateRemoteControlClientMetadata();
>          saveCurrentMedia();
>
> @@ -991,6 +995,7 @@ public class AudioService extends Service {
>          setUpRemoteControlClient();
>          showNotification();
>          updateWidget(this);
> +        broadcastMetadata(this);
>          updateRemoteControlClientMetadata();
>          saveCurrentMedia();
>
> @@ -1227,6 +1232,7 @@ public class AudioService extends Service {
>              setUpRemoteControlClient();
>              showNotification();
>              updateWidget(AudioService.this);
> +            broadcastMetadata(AudioService.this);
>              updateRemoteControlClientMetadata();
>              AudioService.this.saveMediaList();
>              AudioService.this.saveCurrentMedia();
> @@ -1258,6 +1264,7 @@ public class AudioService extends Service {
>              setUpRemoteControlClient();
>              showNotification();
>              updateWidget(AudioService.this);
> +            broadcastMetadata(AudioService.this);
>              updateRemoteControlClientMetadata();
>              determinePrevAndNextIndices();
>          }
> @@ -1478,6 +1485,26 @@ public class AudioService extends Service {
>          sendBroadcast(i);
>      }
>
> +    private void broadcastMetadata(Context context) {
> +        MediaWrapper media = getCurrentMedia();
> +        if (media == null)
> +            return;
> +        String track = media.getTitle();
> +        String artist = Util.getMediaArtist(this, media);
> +        String album = Util.getMediaAlbum(this, media);
> +        long duration = media.getLength();
> +        boolean playing = mLibVLC.isPlaying();
> +
> +        Intent broadcast = new Intent("com.android.music.metachanged");
> +        broadcast.putExtra("track", track);
> +        broadcast.putExtra("artist", artist);
> +        broadcast.putExtra("album", album);
> +        broadcast.putExtra("duration", duration);
> +        broadcast.putExtra("playing", playing);
> +
> +        context.sendBroadcast(broadcast);
> +    }
> +
>      private synchronized void loadLastPlaylist() {
>          SharedPreferences prefs =
> PreferenceManager.getDefaultSharedPreferences(this);
>          String currentMedia = prefs.getString("current_media", "");
> --
> 2.3.5
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>



More information about the vlc-devel mailing list