mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
fix: refined scrobbling logic for the NowPlaying feature across all flavors
This commit is contained in:
parent
5b8e7d1404
commit
1d3a32be5d
2 changed files with 7 additions and 4 deletions
|
|
@ -175,7 +175,6 @@ 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,8 +183,9 @@ class MediaService : MediaLibraryService() {
|
||||||
player.currentMediaItem,
|
player.currentMediaItem,
|
||||||
player.currentPosition
|
player.currentPosition
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
MediaManager.scrobble(player.currentMediaItem, false)
|
||||||
}
|
}
|
||||||
MediaManager.scrobble(player.currentMediaItem, false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPlaybackStateChanged(playbackState: Int) {
|
override fun onPlaybackStateChanged(playbackState: Int) {
|
||||||
|
|
|
||||||
|
|
@ -128,16 +128,19 @@ class MediaService : MediaLibraryService(), SessionAvailabilityListener {
|
||||||
player.currentMediaItem,
|
player.currentMediaItem,
|
||||||
player.currentPosition
|
player.currentPosition
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
MediaManager.scrobble(player.currentMediaItem, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPlaybackStateChanged(playbackState: Int) {
|
override fun onPlaybackStateChanged(playbackState: Int) {
|
||||||
super.onPlaybackStateChanged(playbackState)
|
super.onPlaybackStateChanged(playbackState)
|
||||||
|
|
||||||
if (!player.hasNextMediaItem() &&
|
if (!player.hasNextMediaItem() &&
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +154,7 @@ class MediaService : MediaLibraryService(), SessionAvailabilityListener {
|
||||||
|
|
||||||
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