pragha-music-player / pragha

Pragha is a Lightweight Music Player for GNU/Linux.
GNU General Public License v3.0
173 stars 35 forks source link

Incorrect Implementations of the Can* properties of the MPRIS Specification #123

Open N-Yuki opened 7 years ago

N-Yuki commented 7 years ago

CanGoNext/CanGoPrevious:

CanPlay:

CanPause:

All of the above and CanSeek:

--- There is a **[$5 open bounty](https://www.bountysource.com/issues/47129238-incorrect-implementations-of-the-can-properties-of-the-mpris-specification?utm_campaign=plugin&utm_content=tracker%2F352350&utm_medium=issues&utm_source=github)** on this issue. Add to the bounty at [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F352350&utm_medium=issues&utm_source=github).
matiasdelellis commented 7 years ago

Hi @N-Yuki Thanks for showing me all this .. πŸ˜‰ The implementation tries to be the minimum so that it works in the current MPRIS controlers, and can be improved.. I take note!. πŸ‘

N-Yuki commented 7 years ago

@matiasdelellis No problem, but it's not really about being minimal. CanPlay and CanPause is outright wrong. I initially looked into since the mpris controller in gnome shell wouldn't work with pragha, so I was debugging on both sides to see if it was an issue on the shell side, but I realised that the implementation in pragha was just wrong, causing the controller to not work. Having a broken implementation is quite misleading.

If the goal is minimal implementation, CanPlay and CanPause should just always return true, rather than the current incorrect logic.

On Wed, 12 Jul 2017, 10:09 PM matiasdelellis notifications@github.com wrote:

Hi @N-Yuki https://github.com/n-yuki Thanks for showing me all this .. πŸ˜‰ The implementation tries to be the minimum so that it works in the current MPRIS controlers, and can be improved.. I take note!. πŸ‘

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pragha-music-player/pragha/issues/123#issuecomment-314780869, or mute the thread https://github.com/notifications/unsubscribe-auth/AAecY0kBbuir3lJxH4_C8usQF_IeJCWEks5sNNOhgaJpZM4OUeek .

matiasdelellis commented 7 years ago

Ohh.. You're right!. After merging the WIP/Ampache brach I will fix... Thanks again..

matiasdelellis commented 6 years ago

Hi @N-Yuki Please.. See last commit.. πŸ˜‰

Thanks for all..

N-Yuki commented 6 years ago

Hi @matiasdelellis Looks better!

However, the last point about org.freedesktop.DBus.Properties.PropertiesChanged not being triggered for the above properties could still mean issues with GNOME Shell's MPRIS controller. GNOME Shell checks the CanPlay property before showing the interface, and this property is only checked on application start-up and when signals to org.freedesktop.DBus.Properties.PropertiesChanged for CanPlay are made (due to how GDBusProxy works). This however may also warrant a bug report with GNOME Shell since they should ideally check CanControl, not CanPlay, to decide whether the interface is visible.

Anyway, for Pragha, I remember looking at its MPRIS implementation, and I noticed that it may not be trivial to make this change (maybe keep track of the last returned value for the properties, and see if they've change when there is a track change or something to decide whether a signal should be sent), but if there is no org.freedesktop.DBus.Properties.PropertiesChanged signal sent for CanGoNext/CanGoPrev/CanPlay/CanPause state changes, then it reduces the purpose of having any sort of dynamic logic for these properties. From the perspective of any application that uses GDBusProxy to communicate over DBus, they will see these properties as static since they will see the properties for CanGoNext/CanGoPrev/CanPlay/CanPause as they were on application start-up.

matiasdelellis commented 6 years ago

Hi again, Now it emits all the properties that change, and emits all the properties when initiates a new song... Also each time the playlist changes --Ie. Add new songs--, it emits the properties that change accordingly -- CanNext, etc-.

Please, try it, I think it's functional. πŸ˜„

P.s: Theoretically you could apply these patches in 1.3.3..

matiasdelellis commented 6 years ago

See coments on first commit.. I continue tomorrow.. πŸ˜‰

N-Yuki commented 6 years ago

I agree with the comment on the first commit. It is not consistent at the moment with pragha_backend_get_state (backend) != ST_STOPPED.

As for the signal emitting, looks good! I haven't tested it, but I can see it working with GNOME Shell and other MPRIS controllers that use GDBusProxy now.