Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ class MediaNotificationListener : NotificationListenerService() {
SyncManager.checkAndSyncDeviceStatus(context, forceSync = true)
}

fun hasSignificantMediaChange(old: MediaInfo?, new: MediaInfo?): Boolean {
if (old == null && new == null) return false
if (old == null || new == null) return true
return old.isPlaying != new.isPlaying ||
old.title != new.title ||
old.artist != new.artist ||
old.albumArt != new.albumArt ||
old.albumArtLite != new.albumArtLite ||
old.durationMs != new.durationMs ||
old.isBuffering != new.isBuffering ||
old.likeStatus != new.likeStatus
}

// In-memory cache of like status per track key
private val likeStatusCache = LinkedHashMap<String, String>(32, 0.75f, true)

Expand Down Expand Up @@ -472,7 +485,7 @@ class MediaNotificationListener : NotificationListenerService() {
updateMediaInfo()

// If media info changed, trigger sync
if (previousMediaInfo != currentMediaInfo) {
if (hasSignificantMediaChange(previousMediaInfo, currentMediaInfo)) {
Log.d(TAG, "Media info changed, triggering sync")
SyncManager.onMediaStateChanged(this)
}
Expand Down Expand Up @@ -527,7 +540,7 @@ class MediaNotificationListener : NotificationListenerService() {
updateMediaInfo()

// If media info changed, trigger sync
if (previousMediaInfo != currentMediaInfo) {
if (hasSignificantMediaChange(previousMediaInfo, currentMediaInfo)) {
Log.d(TAG, "Media info changed after notification removal, triggering sync")
SyncManager.onMediaStateChanged(this)
}
Expand Down