[Gambas-user] Triggering org.freedesktop.DBus.Properties.PropertiesChanged

Bruce Steers bsteers4 at gmail.com
Tue Feb 7 19:41:22 CET 2023


On Tue, 7 Feb 2023 at 16:02, Benoit Minisini <
benoit.minisini at gambas-basic.org> wrote:

> Le 07/02/2023 à 16:44, Bruce Steers a écrit :
> >
> > I'm trying to make a dbus mpris interface for a MediaView control.
> >
> > I have some stuff working like cinnamon media control applet will
> > stop/pause/play okay.
> >
> > What i am stuck with at present is being able to trigger the
> > PropertiesChanged event.
> >
> > I have this code...
> >
> > Public Sub _new()
> >
> >    $hDSignal = New DBusSignal(DBus.Session,
> > "org.freedesktop.DBus.Properties", True) As "DBusSignal"
> >
> > End
> >
> >
> > Public Sub DBusSignal_Signal(Sig As String, arg As Variant[])
> >
> >    If Sig <> "PropertiesChanged" Then Return
> >    If arg[0] <> "org.mpris.MediaPlayer2.Player" Then Return
> >
> >    Dim c As Collection = arg[1]
> >    For Each v As Variant In c
> > '    Print c.Key, v
> >      Select c.Key
> >        Case "Volume"
> >          CheckVolumes()
> >        Case "PlaybackStatus"
> >          CheckPlayStates()
> >        Case Else
> >          Print "unhandled:";; c.Key, v
> >
> >      End Select
> >    Next
> >
> > End
> >
> > With that if i click Play/pause in spotify i get the PlaybackStatus
> > PropertiesChanged signal.
> >
> > But i cannot get my mpris interface to trigger the above property change
> > event
> > Is it not supposed to be automatic?
>
> I don't think so. Anyway, you can raise any signal with the
> DBus[Application].Raise() method.
>
> --
> Benoît Minisini.
>

I have tried but cannot seem to make it work.
https://gitlab.com/bsteers4/gb.mediaview.mpris/-/blob/master/.src/MediaView/FMediaPlayer.class#L139

Dim c As New Collection

c.Add(If($hPlayer.State = Media.Playing, "Playing", "Paused"),
"PlaybackStatus")DBus.Raise(DBus_MPRIS._GetDBusObject(),
"org.freedesktop.DBus.Properties.PropertiesChanged",
["org.mpris.MediaPlayer2.Player", c, Null])

Not entirely sure what DBusObject to use or the property / interface
name. (have got a bit out of my depth i think)

I've made a gitlab project for this if anyone wants to see if they can
get it working better.
https://gitlab.com/bsteers4/gb.mediaview.mpris

Is a copy of the MediaView control with a few modifications like
accessing the internal MediaPlayer control to get State.

Plus a dbus class for the mpris.MediaPlayer2 that can control the MediaView
Todo: the MediaView does not fire property changes correctly.


Cinnamon media controller applet can play/pause and read the metadata
(it's glitchy though and it's play button does not change to pause as
it does not get the property change)

My own media controller application can play/pause/seek/position/set volume

but it sometimes reads Null when getting the properties from this
application (not others).

Respects

BruceS

(ps, sorry if this post is badly formatted)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230207/b95b4e1b/attachment-0001.htm>


More information about the User mailing list