This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Amarok: set song rating via DBus

Tags: None
(comma "," separated)
User avatar
belnac
Registered Member
Posts
13
Karma
0
OS

Amarok: set song rating via DBus

Tue Jun 05, 2012 6:45 pm
Anyone knows how to set the rating of the song currently playing on Amarok via DBus?

The following,
Code: Select all
qdbus org.kde.amarok /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Rate

doesn't return the actual song rating but something else.

Likewise, ie,
Code: Select all
qdbus org.kde.amarok /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Set org.mpris.MediaPlayer2.Player Rate 4

doesn't seem to do anything as the 'Rate' property remains unchanged. No errors or warnings are produced though.

I know that back when I was using the KDE DE I was once able to configure KRemote to set Amarok's song rating via DBus upon pressing a button on my remote control and, as such, I know it's doable. Unfortunately though I'm not using the KDE DE at the moment and don't have the System Settings's and KRemote's amazing GUI available to try and look for the the actual interface, method/property that does what I'm after.

Anyone knows how, I wonder?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Moved to Amarok forum.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
Mamarok
Manager
Posts
6071
Karma
16
OS
Did you have a look at the wiki here http://amarok.kde.org/wiki/Development/ ... _HowTo_2.0 ?


Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ...
User avatar
belnac
Registered Member
Posts
13
Karma
0
OS

Re: Amarok: set song rating via DBus

Thu Jun 07, 2012 11:35 am
Mamarok wrote:Did you have a look at the wiki here http://amarok.kde.org/wiki/Development/ ... _HowTo_2.0 ?

I did, yes. I read that particular page several pages and also the one on the MPRIS interface located here. [http://xmms2.org/wiki/MPRIS]

But no luck so far!
User avatar
strohel
KDE Developer
Posts
54
Karma
0
OS

Re: Amarok: set song rating via DBus

Thu Jun 07, 2012 11:50 am
Hmm, perhaps it's just not implemented on the Amarok side. Have you checked the code?
User avatar
belnac
Registered Member
Posts
13
Karma
0
OS

Re: Amarok: set song rating via DBus

Thu Jun 07, 2012 11:56 am
strohel wrote:Hmm, perhaps it's just not implemented on the Amarok side. Have you checked the code?


Not yet, no, but only because I'm fairly convinced (though with some doubts now lol) that it can be done via DBus. I know for a fact that back when I was using the KDE DE I had a setup whereby pressing the 1-5 numeric buttons on my remote control triggered song rating in Amarok. What I'm not now 100% sure is that the setup relied on signals sent via DBus, though that's the impression I'm under.
User avatar
belnac
Registered Member
Posts
13
Karma
0
OS

Re: Amarok: set song rating via DBus

Thu Jun 07, 2012 12:12 pm
Seems like it isn't supported via DBus after all!

Solved this by installing KDE System settings and KRemoteControl and then setting up workspace keypress events for each of the 1-5 keys on my remote control. For this to work, however, I had to also setup shortcuts in amarok to respond to the keypresses defined in KRemoteControl. Note that defining global shortcuts (instead of regular shortcuts) will not work.
User avatar
strohel
KDE Developer
Posts
54
Karma
0
OS

Re: Amarok: set song rating via DBus

Thu Jun 07, 2012 12:17 pm
belnac wrote:Seems like it isn't supported via DBus after all!
Then please go and implement it, http://reviewboard.kde.org/ is your friend! ;)
User avatar
belnac
Registered Member
Posts
13
Karma
0
OS
strohel wrote:
belnac wrote:Seems like it isn't supported via DBus after all!
Then please go and implement it, http://reviewboard.kde.org/ is your friend! ;)


I certainly would be willing to but I don't think a patch would ever be accepted since, to quote this page, "Amarok 2.0 interface implements MPRIS 1.0 DBus API. So I think first and foremost the devs or whoever is responsible for the project would have to agree to either extend or change the standard as implemented by Amarok.

Anyway, I've found an even better and much more elegant solution for my little predicament. It involves using irexec (which I'm already using anyway) and a DBus call to invoke Amarok's shortcuts, as given:

Code: Select all
qdbus org.kde.kglobalaccel /component/amarok org.kde.kglobalaccel.Component.invokeShortcut rate1


So, in my .lircrc, I have, (the following toggles between 1 star or half rating)

Code: Select all
begin
  button = 1
  prog   = irexec
  config = qdbus org.kde.kglobalaccel /component/amarok org.kde.kglobalaccel.Component.invokeShortcut rate1
end


Hope this helps someone!
User avatar
strohel
KDE Developer
Posts
54
Karma
0
OS
I certainly would be willing to but I don't think a patch would ever be accepted since, to quote this page, "Amarok 2.0 interface implements MPRIS 1.0 DBus API.
Oh, the wiki page is hopelessly outdated (you could have told from the "Amarok 2.0"), we now support only MPRIS 2.

So I think first and foremost the devs or whoever is responsible for the project would have to agree to either extend or change the standard as implemented by Amarok.
I am an Amarok developer and I'll happily accept your patch! ;)

Anyway, I've found an even better and much more elegant solution for my little predicament.
Anything that doesn't fix Amarok MPRIS 2 confomance is just a work-around.
User avatar
Sentynel
KDE Developer
Posts
285
Karma
1
OS
I had a look at the DBus interface. I'm not sure what the org.mpris.MediaPlayer2.Player Rate property actually refers to, but the one you're interested in is in the org.mpris.MediaPlayer2.Player Metadata property as xesam:userRating. You should be able to change that.


User avatar
belnac
Registered Member
Posts
13
Karma
0
OS

Re: Amarok: set song rating via DBus

Sun Jun 10, 2012 12:01 pm
Thank you for that, Sentynel. I had come across the metadata property before but was under the impression it was readonly. Will definitely be having a closer look now!
User avatar
Sentynel
KDE Developer
Posts
285
Karma
1
OS
Oh, I didn't check if it's read only. You might be out of luck (again) if it is.


User avatar
belnac
Registered Member
Posts
13
Karma
0
OS
I think it is:

Code: Select all
~$ qdbus org.mpris.MediaPlayer2.amarok /org/mpris/MediaPlayer2 |grep -i meta
property read QVariantMap org.mpris.MediaPlayer2.Player.Metadata


It's alright though; I've got it working anyhow! Thank you for your help.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]