-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mpris2: send more metadata about current track #165
mpris2: send more metadata about current track #165
Conversation
xesam:albumArtist, xesam:comment, xesam:genre, xesam:composer, xesam:trackNumber, xesam:discNumber
…t_int*` functions
Set default integer values to -1, as used by tuple to indicate unset; Remove redundant checks; Add empty string check before GVariant
This is how a proper merge request should look like. 👍 Thanks also for the great and detailed description.
I don't see why it should impact file size and performance noticeably. So I am in favor of merging this. Remarks from my side:
@jlindgren90: Could you also review this since the MPRIS plugin was mostly written by you? Thanks. |
This looks good to me. I also don't mind using |
It would be nice to squash the commits when merging. |
Many thanks for the swift review and your kind words! I adjusted the coding style to fit the rest of the code (9e9726b). Regarding if (meta.artist)
add_g_variant_arr_str ("xesam:artist", {meta.artist}, elems); if (meta.artist)
add_g_variant_arr_str ("xesam:artist",
str_list_to_index (meta.artist, ""), elems); I kept this change on a separate branch for your consideration: https://github.com/onegentig/audacious-plugins/commit/e545acf0a034302a1cdbe786d0bdea9da3859fe6. For And I will also merge |
@onegentig: Thanks for the update and sorry for the late reply. But it's vacation time after all. :) @jlindgren90: Could you please check commit https://github.com/onegentig/audacious-plugins/commit/e545acf0a034302a1cdbe786d0bdea9da3859fe6? Is there a simpler way for the initialization? |
Perfectly understandable, there’s no rush anywhere. 🙂👍 While Index<String> str_to_idx(const char * str) {
Index<String> idx;
if (str)
idx.append(str);
return idx;
} …employed as follows: if (meta.artist)
add_g_variant_arr_str ("xesam:artist",
str_to_idx (meta.artist), elems); |
I would avoid constructing an |
I have tested it now and can confirm that Given the efficacy of EDIT: Squash-merged (62a9935). |
Co-authored-by: John Lindgren <john@jlindgren.net>
0137b7f
into
audacious-media-player:master
Merged now, thanks again. 👍 |
Thank you for the merge and the guidance. Glad to contribute. |
This PR adds more MPRIS2 metadata to broadcast about the current track to "MPRIS2 Server" plugin.
Compared to players like Supersonic, Rhythmbox, DeaDBeeF (via plugin) or Spotify, Audacious does not provide much metadata about the currently playing track.
Intercepted Examples (using dbus-python)
Audacious: (7)
Rhythmbox: (15)
Spotify: (11)
VLC Media Player: (14)
As is, Audacious only provides
xesam:title
,xesam:artist
,xesam:album
,mpris:length
,xesam:artUrl
(ex. "audacious-temp-TNGWQ2") andxesam:url
(local path to played file).This PR adds the following fields:
xesam:albumArtist
xesam:comment
xesam:genre
xesam:composer
xesam:trackNumber
xesam:discNumber
Example
Motivation
Providing richer metadata supports better interoperability and potentially user experience when using other tools alongside Audacious. MPRIS2 metadata is commonly used be player controllers or other music-related apps, like Last.FM/ListenBrainz scrobblers (ex. mpris-scrobbler or rescrobbled – needs as much data as it can for profile display and recording detection), Discord rich presence (multiple – the pretty fields don’t fill themselves) and others. I was working on my own ListenBrainz scrobbler, and found the amount of data lacking. For some tracks, I had to manually link the track to MusicBrainz – it didn’t have enough data to link it itself.
Another potential applicability are voice assistants and smart devices – a prompt "Play track 5 from disc 2 of simulated_worlds album" would only be possible with this additional metadata.
However, I recognise this may be of minor interest to Audacious and the downsides of added file size and performance may outweigh the positives. It is entirely to you all to decide, if this is a desirable addition.
Notes
Codebase Changes
MPRIS2 server source code was refactored to simplify adding new fields and somewhat modernise working with metadata.
MPRIS2Metadata
structelems
, storage of DBus values to broadcast, was changed from an array tostd::vector<GVariant *>
<vector>
!GValues
toelems
(multiple for different value types)Remaining Metadata
There are some metadata defined in MPRIS2 specification that I wasn’t able to add, as they were not present in the metadata tuple.
xesam:audioBPM
xesam:autoRating
(automatically-generated rating)xesam:firstUsed
(datetime of first listen)xesam:lastUsed
(datetime of last listen)xesam:useCount
(number of times listened)xesam:userRating
There are two fields I could add, but chose not to without consultation:
xesam:contentCreated
(release date) – it would be possible to set this to a year by convertingYear
to a string, though this would require another new import –<string>
– and I was unsure if I can get away with that after already adding<vector>
. As for month and date, I was unsure if I can obtain it… MaybeDate
? What format is it in? Seems like a lot of validation required, but idk..xesam:asText
(lyrics) – very simple to add, but I was not initially sure if it’s worth it. This is potentially a very long string and most tools usually fetch the lyrics themselves. I am unsure of the weight this might have, maybe I am just paranoid.I implemented both lyrics and release year on separate branches, see following commits:
I would like to hear your thoughts on them before including them.
I will appreciate any feedback or suggestions on how to make this work.
Thank you for your time and consideration,
– onegen