Bug 341205

Summary: Media Controller cant handle tomahawk at all
Product: [Plasma] plasmashell Reporter: FabiB <plusfabi>
Component: Media PlayerAssignee: Kai Uwe Broulik <kde>
Severity: major CC: e.m.a.t.i.r.o.v, jckeerthan, kde, mklapetek
Priority: NOR    
Version: master   
Target Milestone: 1.0   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 5.3.0
Sentry Crash Report:
Attachments: screenshot
D-Bus log from bustle
plasmashell log

Description FabiB 2014-11-23 23:16:54 UTC
in kde plasma5 the mediacontroller cant correctly use tomahawk. 
'next track' is working but thats it.

qdbus org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2                           
property read bool org.mpris.MediaPlayer2.CanQuit
property read bool org.mpris.MediaPlayer2.CanRaise
property read QString org.mpris.MediaPlayer2.DesktopEntry
property read bool org.mpris.MediaPlayer2.HasTrackList
property read QString org.mpris.MediaPlayer2.Identity
property read QStringList org.mpris.MediaPlayer2.SupportedMimeTypes
property read QStringList org.mpris.MediaPlayer2.SupportedUriSchemes
method void org.mpris.MediaPlayer2.Quit()
method void org.mpris.MediaPlayer2.Raise()
property read bool org.mpris.MediaPlayer2.Player.CanControl
property read bool org.mpris.MediaPlayer2.Player.CanGoNext
property read bool org.mpris.MediaPlayer2.Player.CanGoPrevious
property read bool org.mpris.MediaPlayer2.Player.CanPause
property read bool org.mpris.MediaPlayer2.Player.CanPlay
property read bool org.mpris.MediaPlayer2.Player.CanSeek
property readwrite QString org.mpris.MediaPlayer2.Player.LoopStatus
property read double org.mpris.MediaPlayer2.Player.MaximumRate
property read QVariantMap org.mpris.MediaPlayer2.Player.Metadata
property read double org.mpris.MediaPlayer2.Player.MinimumRate
property read QString org.mpris.MediaPlayer2.Player.PlaybackStatus
property read qlonglong org.mpris.MediaPlayer2.Player.Position
property readwrite double org.mpris.MediaPlayer2.Player.Rate
property readwrite bool org.mpris.MediaPlayer2.Player.Shuffle
property readwrite double org.mpris.MediaPlayer2.Player.Volume
method void org.mpris.MediaPlayer2.Player.Next()
method void org.mpris.MediaPlayer2.Player.OpenUri(QString Uri)
method void org.mpris.MediaPlayer2.Player.Pause()
method void org.mpris.MediaPlayer2.Player.Play()
method void org.mpris.MediaPlayer2.Player.PlayPause()
method void org.mpris.MediaPlayer2.Player.Previous()
method void org.mpris.MediaPlayer2.Player.Seek(qlonglong Offset)
signal void org.mpris.MediaPlayer2.Player.Seeked(qlonglong Position)
method void org.mpris.MediaPlayer2.Player.SetPosition(QDBusObjectPath TrackId, qlonglong Position)
method void org.mpris.MediaPlayer2.Player.Stop()
method QDBusVariant org.freedesktop.DBus.Properties.Get(QString interface_name, QString property_name)
method QVariantMap org.freedesktop.DBus.Properties.GetAll(QString interface_name)
method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant value)
method QString org.freedesktop.DBus.Introspectable.Introspect()
method QString org.freedesktop.DBus.Peer.GetMachineId()
method void org.freedesktop.DBus.Peer.Ping()

what works is:
qdbus org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous

qdbus org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

qdbus org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play

qdbus org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

but only via commandline. I cant press the buttons in the MediaController
Comment 1 Kai Uwe Broulik 2014-11-24 22:05:26 UTC
Can you check the output of CanGoPrevious/CanGoNext/CanPause/CanPlay? If that returns false, it's a client bug since the mediacontroller disables the button when the client announces it cannot go back/forward/pause/play
Comment 2 FabiB 2014-11-24 23:08:51 UTC
Created attachment 89719 [details]

qdbus org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.CanGoPrevious 

qdbus org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.CanGoNext

qdbus org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.CanPause

qdbus org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.CanPlay

No they're all true
Comment 3 Mikhail Ivchenko 2014-12-07 12:50:28 UTC
Created attachment 89856 [details]
D-Bus log from bustle

For me all buttons except "pause" are disabled. (Pause doesn't work too anyway).
Comment 4 Keerthan Jaic 2015-01-12 21:06:00 UTC
If I run kquitapp5 plasmashell and open it again, then the media controls work fine.
Comment 5 Keerthan Jaic 2015-01-12 21:22:37 UTC
It looks like the bug always occurs if Tomahawk is opened after plasmashell. It looks like the plasmoid bugging out since it querys mpris before tomahawk's service comes online. I've attached the relavent logs.
Comment 6 Keerthan Jaic 2015-01-12 21:23:05 UTC
Created attachment 90374 [details]
plasmashell log
Comment 7 Kai Uwe Broulik 2015-01-12 21:24:20 UTC
Thanks! I've seen that with VLC but I thought that was due to us blacklisting the parent vlc instance (it creates multiple mpris services), so this is a different issue then if it affects Tomahawk as well.
Comment 8 Kai Uwe Broulik 2015-02-18 15:54:04 UTC
This seems to have been fixed by dropping the VLC workaround.
Comment 9 Martin Klapetek 2015-02-18 16:11:08 UTC
How would that be related? That workaround just completely skipped/ignored one vlc mpris instance, that should in no way affect tomahawk, no?
Comment 10 FabiB 2015-05-06 17:47:23 UTC
should this be fixed in Plasma 5.2? Because i'm still not able to controll tomahawk via plasma widget
Comment 11 FabiB 2015-05-06 17:49:49 UTC
5.3* not .2
Comment 12 FabiB 2015-06-14 11:24:24 UTC
is there something we can do to help you fixing this bug? because it really kills my workflow on plasma5
Comment 13 Kai Uwe Broulik 2015-06-16 18:09:39 UTC
I can control Tomahawk using the applet, seeking, pause, next, etc. The Previous/Next button is  a bit glitchy (the Previous button is greyed out all the time whereas the Next button is never, even at the end of the playlist). Sometimes I cannot skip to the next track but that doesn't work when I go directly through DBus either when that happens.
Comment 14 FabiB 2015-06-16 19:25:22 UTC
this is the situation for me on 4 computers:

i simply cant use the controlls..

Tomahawk 0.8.4
Plasma 5.3.1
Comment 15 Kai Uwe Broulik 2015-06-16 19:29:01 UTC
I'm using Tomahawk 0.7.0
Martin, any idea on this one?
Comment 16 Martin Klapetek 2015-06-25 10:13:06 UTC
Tomahawk 0.7.0 here, works fine.

Tomahawk 0.8.4 does not. Perhaps they broke something. I'll have a closer look.
Comment 17 Martin Klapetek 2015-06-25 12:48:33 UTC
Alright so issuing the dbus command to tomahawk directly (qdbus) works fine. However running bustle I can see that when you press play/pause in the applet, no dbus command is sent at all, so this is clearly a bug in the applet.
Comment 18 Martin Klapetek 2015-06-25 14:10:28 UTC
I know exactly what's up. Upon opening, this is what tomahawk sends to Plasma for "org.freedesktop.DBus.Properties.GetAll org.mpris.MediaPlayer2.Player"

@a{sv} {"CanControl": <@b True>, "CanGoNext": <@b False>, "CanGoPrevious": <@b False>, "CanPause": <@b False>, "CanPlay": <@b False>, "CanSeek": <@b True>, "LoopStatus": <@s "None">, "MaximumRate": <@d 1.0>, "Metadata": <@a{sv} {}>, "MinimumRate": <@d 1.0>, "PlaybackStatus": <@s "Stopped">, "Position": <@x 0>, "Rate": <@d 1.0>, "Shuffle": <@b False>, "Volume": <@d 0.75>}

The same query from qdbus *when the playback is on*.

@a{sv} {"CanControl": <@b True>, "CanGoNext": <@b False>, "CanGoPrevious": <@b False>, "CanPause": <@b True>, "CanPlay": <@b True>, "CanSeek": <@b True>, "LoopStatus": <@s "None">, "MaximumRate": <@d 1.0>, "Metadata": <@a{sv} {"mpris:artUrl": <@s "file:///tmp/Dragonforce_Inhuman%20Rampage%20(Bonus%20CD)_tomahawk_cover.png.ou9476">, "mpris:length": <@x 441000000>, "mpris:trackid": <@o "/track/b96d6647dd6745219ed0c9cee4ee14dd">, "xesam:album": <@s "Inhuman Rampage (Bonus CD)">, "xesam:artist": <@as ["Dragonforce"]>, "xesam:title": <@s "Through The Fire And Flames">}>, "MinimumRate": <@d 1.0>, "PlaybackStatus": <@s "Playing">, "Position": <@x 207138000>, "Rate": <@d 1.0>, "Shuffle": <@b False>, "Volume": <@d 0.75>}.

I just noticed that this has more data and also things actually work when tomahawk is running and plasma is restarted.

It kinda makes sense - tomahawk sets "CanPause/CanPlay" only when there is an active playback. Now the dataengine is actually checking for these being present and if they are not, the controls won't have any effect.

This looks like a bug in tomahawk after all because it does signal out "PropertiesChanged" for various properties, but never for "CanPause/CanPlay".

On the other hand, perhaps the controls should be working when "CanControl" is true (which it is from the beginning), or the applet should query again for "CanPause/CanPlay" when the playback status changes.

All and all, ultimately this bug is because of how vague the mpris2 spec is. Again.
Comment 19 Martin Klapetek 2015-06-25 14:27:28 UTC
Couple clarifications after I reread the spec (after years):

When this property changes, the org.freedesktop.DBus.Properties.PropertiesChanged signal is emitted with the new value.
Whether playback can be started using Play or PlayPause.
Note that this is related to whether there is a "current track": the value should not depend on whether the track is currently paused or playing. In fact, if a track is currently playing (and CanControl is true), this should be true.

So in fact, the behavior our media applet has is absolutely correct. When there is no song in the playlist, "Play/PlayPause" wouldn't do anything and in that case "CanPlay/CanPause" is correctly false (according to spec). When the playback changes, Tomahawk however must update the "CanPlay/CanPause" property (as per the spec) which it doesn't and this should be reported to Tomahawk devs. Furthermore, Tomahawk's own context menu has "Play" action which also does nothing when pressed (it also has enabled "Play" action in the main window which also does nothing at all).

So, I take back my previous comment about this bug coming from the vagueness of mpris, this is, in fact a bug in Tomahawk as can be seen all around its own UI.

I'd probably still recommend to recheck for "CanPlay/CanPause" ourselves when the playback changes; in the worst case we update the property twice (once from players sending the "PropertiesChanged" signal).

But as far as I'm concerned, this bug can be closed as INVALID/UPSTREAM.

Comment 20 David Edmundson 2017-02-28 21:03:51 UTC
Closing as per Martin K's in depth analysis