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

Thomas Guillem thomas at gllm.fr
Thu Apr 9 08:51:40 CEST 2015


Hi,

On Wed, Apr 8, 2015, at 22:19, Guillaume 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
> 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);

You should use media.getArtist() and media.getAlbum() instead of the
Util functions. Indeed the Util functions return the translation of
"Unknown Artist/Album" if the artist/album are NULL and we don't want
that. Maybe if artist or album are null you can abort and don't send the
broadcast too.

> + 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", "");

Otherwise, fine with me, thanks for you contribution.

> --
> 2.3.5
>
> _________________________________________________
> vlc-devel mailing list To unsubscribe or modify your subscription
> options: https://mailman.videolan.org/listinfo/vlc-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20150409/51ca0605/attachment.html>


More information about the vlc-devel mailing list