[vlc-devel] [PATCH] [Android] Implement Scrobbling compatibility (#11904)
Guillaume
h.guillaume at gmail.com
Wed Apr 8 22:19:26 CEST 2015
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);
+ 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20150408/575e7627/attachment.html>
More information about the vlc-devel
mailing list