mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 09:53:33 +00:00
Send "now playing" scrobbles to server.
This commit is contained in:
parent
293b0f71c8
commit
d8c8a783de
5 changed files with 11 additions and 9 deletions
|
|
@ -104,10 +104,10 @@ public class SongRepository {
|
||||||
return randomSongsSample;
|
return randomSongsSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrobble(String id) {
|
public void scrobble(String id, Boolean submission) {
|
||||||
App.getSubsonicClientInstance(false)
|
App.getSubsonicClientInstance(false)
|
||||||
.getMediaAnnotationClient()
|
.getMediaAnnotationClient()
|
||||||
.scrobble(id)
|
.scrobble(id, submission)
|
||||||
.enqueue(new Callback<ApiResponse>() {
|
.enqueue(new Callback<ApiResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
|
public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
|
||||||
|
|
|
||||||
|
|
@ -293,9 +293,9 @@ public class MediaManager {
|
||||||
getQueueRepository().setPlayingPausedTimestamp(mediaItem.mediaId, ms);
|
getQueueRepository().setPlayingPausedTimestamp(mediaItem.mediaId, ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void scrobble(MediaItem mediaItem) {
|
public static void scrobble(MediaItem mediaItem, Boolean submission) {
|
||||||
if (mediaItem != null && Preferences.isScrobblingEnabled()) {
|
if (mediaItem != null && Preferences.isScrobblingEnabled()) {
|
||||||
getSongRepository().scrobble(mediaItem.mediaMetadata.extras.getString("id"));
|
getSongRepository().scrobble(mediaItem.mediaMetadata.extras.getString("id"), submission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ public class MediaAnnotationClient {
|
||||||
return mediaAnnotationService.setRating(subsonic.getParams(), id, rating);
|
return mediaAnnotationService.setRating(subsonic.getParams(), id, rating);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Call<ApiResponse> scrobble(String id) {
|
public Call<ApiResponse> scrobble(String id, Boolean submission) {
|
||||||
Log.d(TAG, "scrobble()");
|
Log.d(TAG, "scrobble()");
|
||||||
return mediaAnnotationService.scrobble(subsonic.getParams(), id);
|
return mediaAnnotationService.scrobble(subsonic.getParams(), id, submission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,5 +20,5 @@ public interface MediaAnnotationService {
|
||||||
Call<ApiResponse> setRating(@QueryMap Map<String, String> params, @Query("id") String id, @Query("rating") int rating);
|
Call<ApiResponse> setRating(@QueryMap Map<String, String> params, @Query("id") String id, @Query("rating") int rating);
|
||||||
|
|
||||||
@GET("scrobble")
|
@GET("scrobble")
|
||||||
Call<ApiResponse> scrobble(@QueryMap Map<String, String> params, @Query("id") String id);
|
Call<ApiResponse> scrobble(@QueryMap Map<String, String> params, @Query("id") String id, @Query("submission") Boolean submission);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,7 @@ class MediaService : MediaLibraryService() {
|
||||||
|
|
||||||
override fun onTracksChanged(tracks: Tracks) {
|
override fun onTracksChanged(tracks: Tracks) {
|
||||||
ReplayGainUtil.setReplayGain(player, tracks)
|
ReplayGainUtil.setReplayGain(player, tracks)
|
||||||
|
MediaManager.scrobble(player.currentMediaItem, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onIsPlayingChanged(isPlaying: Boolean) {
|
override fun onIsPlayingChanged(isPlaying: Boolean) {
|
||||||
|
|
@ -184,6 +185,7 @@ class MediaService : MediaLibraryService() {
|
||||||
player.currentPosition
|
player.currentPosition
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
MediaManager.scrobble(player.currentMediaItem, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPlaybackStateChanged(playbackState: Int) {
|
override fun onPlaybackStateChanged(playbackState: Int) {
|
||||||
|
|
@ -192,7 +194,7 @@ class MediaService : MediaLibraryService() {
|
||||||
playbackState == Player.STATE_ENDED &&
|
playbackState == Player.STATE_ENDED &&
|
||||||
player.mediaMetadata.extras?.getString("type") == Constants.MEDIA_TYPE_MUSIC
|
player.mediaMetadata.extras?.getString("type") == Constants.MEDIA_TYPE_MUSIC
|
||||||
) {
|
) {
|
||||||
MediaManager.scrobble(player.currentMediaItem)
|
MediaManager.scrobble(player.currentMediaItem, true)
|
||||||
MediaManager.saveChronology(player.currentMediaItem)
|
MediaManager.saveChronology(player.currentMediaItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -206,7 +208,7 @@ class MediaService : MediaLibraryService() {
|
||||||
|
|
||||||
if (reason == Player.DISCONTINUITY_REASON_AUTO_TRANSITION) {
|
if (reason == Player.DISCONTINUITY_REASON_AUTO_TRANSITION) {
|
||||||
if (oldPosition.mediaItem?.mediaMetadata?.extras?.getString("type") == Constants.MEDIA_TYPE_MUSIC) {
|
if (oldPosition.mediaItem?.mediaMetadata?.extras?.getString("type") == Constants.MEDIA_TYPE_MUSIC) {
|
||||||
MediaManager.scrobble(oldPosition.mediaItem)
|
MediaManager.scrobble(oldPosition.mediaItem, true)
|
||||||
MediaManager.saveChronology(oldPosition.mediaItem)
|
MediaManager.saveChronology(oldPosition.mediaItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue