mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-05 00:33:06 +00:00
fix: resolved issue with scrobbling the last track
This commit is contained in:
@@ -186,6 +186,17 @@ class MediaService : MediaLibraryService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPlaybackStateChanged(playbackState: Int) {
|
||||||
|
super.onPlaybackStateChanged(playbackState)
|
||||||
|
if (!player.hasNextMediaItem() &&
|
||||||
|
playbackState == Player.STATE_ENDED &&
|
||||||
|
player.mediaMetadata.extras?.getString("type") == Constants.MEDIA_TYPE_MUSIC
|
||||||
|
) {
|
||||||
|
MediaManager.scrobble(player.currentMediaItem)
|
||||||
|
MediaManager.saveChronology(player.currentMediaItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPositionDiscontinuity(
|
override fun onPositionDiscontinuity(
|
||||||
oldPosition: Player.PositionInfo,
|
oldPosition: Player.PositionInfo,
|
||||||
newPosition: Player.PositionInfo,
|
newPosition: Player.PositionInfo,
|
||||||
|
|||||||
@@ -259,6 +259,17 @@ class MediaService : MediaLibraryService(), SessionAvailabilityListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPlaybackStateChanged(playbackState: Int) {
|
||||||
|
super.onPlaybackStateChanged(playbackState)
|
||||||
|
if (!player.hasNextMediaItem() &&
|
||||||
|
playbackState == Player.STATE_ENDED &&
|
||||||
|
player.mediaMetadata.extras?.getString("type") == Constants.MEDIA_TYPE_MUSIC
|
||||||
|
) {
|
||||||
|
MediaManager.scrobble(player.currentMediaItem)
|
||||||
|
MediaManager.saveChronology(player.currentMediaItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPositionDiscontinuity(
|
override fun onPositionDiscontinuity(
|
||||||
oldPosition: Player.PositionInfo,
|
oldPosition: Player.PositionInfo,
|
||||||
newPosition: Player.PositionInfo,
|
newPosition: Player.PositionInfo,
|
||||||
|
|||||||
Reference in New Issue
Block a user