fix: prevent station name from being added to metadata history

- Skip adding metadata to the history list if the metadata string matches the current station name.
- Move `currentMediaItem` retrieval earlier in the processing logic to facilitate the station name comparison.
This commit is contained in:
Michatec committed 2026-10-31 21:07:47 +01:00
1 parent 33ff113989
commit 008ac4bc34
1 file changed
+6 -1
@@ -420,6 +420,12 @@ class PlayerService : MediaLibraryService(), SharedPreferences.OnSharedPreferenc
return
}
val currentMediaItem = player.currentMediaItem
val stationName = currentMediaItem?.let { CollectionHelper.getStation(collection, it.mediaId).name } ?: ""
if (metadataString == stationName) {
return
}
// remove duplicates
if (metadataHistory.contains(metadataString)) {
metadataHistory.removeAll { it == metadataString }
@@ -434,7 +440,6 @@ class PlayerService : MediaLibraryService(), SharedPreferences.OnSharedPreferenc
PreferencesHelper.saveMetadataHistory(metadataHistory)
if (metadata.isNotEmpty()) {
val currentMediaItem = player.currentMediaItem
if (currentMediaItem != null && currentMediaItem.mediaMetadata.title?.toString() != metadataString) {
val stationName = CollectionHelper.getStation(collection, currentMediaItem.mediaId).name.ifEmpty {
currentMediaItem.mediaMetadata.artist?.toString() ?: ""