FichteFoll / discordrp-mpris

Discord Rich Presence through media players providing the mpris2 dbus interface
MIT License
86 stars 19 forks source link

mpc-qt support #6

Closed BobbyWibowo closed 6 years ago

BobbyWibowo commented 6 years ago

Hi there, thanks for the great job. It's been working pretty well with mpv and others, but I'm having some issues with mpc-qt.

First, on any tracks, their "artist" will always be a string instead of a list of strings. So the current code will end up joining every character of the string with & (e.i. Jack becomes J & a & c & k). Adding a little patch, where it will add the value into a list IF its type is a string, fixed the issue for me (on a side note I'm not too familiar with Python so please excuse me if my phrasing sound odd or something).

Second, mpc-qt seem to update its mpris thingy every second even if it's still playing the same track, so the elapsed time status in Discord will always reset back to 00.00 after a few seconds. I noticed the same behavior with other project (not mine) that would also monitor mpris. Basically it would report that mpc-qt would keep on updating its track position every second, but it wouldn't report anything like that for any other players (including mpv) even when I tried to manually seek other position. Then again I don't really understand this whole mpris thingy either.

FichteFoll commented 6 years ago

Thanks for the reports. I'll look into them in due time.

Do you know whether mpc-qt has some kind of icon for its name? I'd like to add that to the icon list if there is one, once I confirmed it is working properly.

BobbyWibowo commented 6 years ago

It doesn't have any fancy icon that I'm aware of. At the moment it's using this icon, including for the occasional Windows releases (it's an SVG though, so you may have to manually make a PNG version or something?). I think I'd also prefer having that icon used instead.

BobbyWibowo commented 6 years ago

Hi again, so I happened to be free and wanted to look more into it. I managed to figure out the issue. For mpc-qt, its position timestamp will always be in milliseconds instead of microseconds, so it'll always be converted to 00:00. Thus adding a patch where its position will be multiplied by 1000 if the active player is mpc-qt would solve it. It feels kinda awkward having a special treatment for it tho, but oh well. Here's some sneak peeks: Playing Paused (kinda ended up making my own Discord app to have mpc-qt logo) https://github.com/BobbyWibowo/discordrp-mpris/commits/mpc-qt-patch

FichteFoll commented 6 years ago

At the moment it's using this icon

I'll take it.

its position timestamp will always be in milliseconds instead of microseconds

Ah well, that was unexpected. I submitted a PR upstream so I don't have to add a workaround myself, since I could run into issues when that gets fixed and I still have the workaround in place. See https://github.com/cmdrkotori/mpc-qt/pull/203. Hopefully that'll get released fast enough for people using it (assuming they're not on debian or something).

I also added https://github.com/cmdrkotori/mpc-qt/issues/204 because fixing that myself wouldn't be as quick. However, I can add a reasonably simple workaround for this, similar to https://github.com/BobbyWibowo/discordrp-mpris/commit/9451315b51a5c2b4e34c5a25c925d8645179fc1b.

From https://github.com/BobbyWibowo/discordrp-mpris/commit/48ff08587289ab5b9a2a62223e30b81a445cf4ac I presume clementine is supported, too? I'll test that (and add an icon) as well, if it works. I can't test the KDE Plasma stuff though because I'm not running that and would probably need a VM. If you say these work, that's probably good enough.

FichteFoll commented 6 years ago

Both your mentioned issues are fixed upstream. You'll need a version built from master to use them, of course. I declared support for mpc-qt in 1d944c696e29e09e8ccae3a82bb97cf4e3c31f96 and added an icon to my app.