more mpris

This commit is contained in:
Erica Z 2024-10-26 11:34:12 +02:00
parent efc639367b
commit 347cb55c9d

View file

@ -40,7 +40,7 @@ class MprisPlayer : Object {
internal signal void on_stop (); internal signal void on_stop ();
internal signal void on_play (); internal signal void on_play ();
internal signal void on_seek (int64 offset); internal signal void on_seek (int64 offset);
internal signal void on_set_position (string track_id, int64 position); internal signal void on_set_position (ObjectPath track_id, int64 position);
public void next () throws Error { this.on_next (); } public void next () throws Error { this.on_next (); }
public void previous () throws Error { this.on_previous (); } public void previous () throws Error { this.on_previous (); }
@ -49,7 +49,7 @@ class MprisPlayer : Object {
public void stop () throws Error { this.on_stop (); } public void stop () throws Error { this.on_stop (); }
public void play () throws Error { this.on_play (); } public void play () throws Error { this.on_play (); }
public void seek (int64 offset) throws Error { this.on_seek (offset); } public void seek (int64 offset) throws Error { this.on_seek (offset); }
public void set_position (string track_id, int64 position) throws Error { this.on_set_position (track_id, position); } public void set_position (ObjectPath track_id, int64 position) throws Error { this.on_set_position (track_id, position); }
public void open_uri (string uri) throws Error { assert (false); } public void open_uri (string uri) throws Error { assert (false); }
public signal void seeked (int64 position); public signal void seeked (int64 position);
@ -152,6 +152,12 @@ class MprisPlayer : Object {
if (playbin.state == PlaybinState.PAUSED) playbin.play (); if (playbin.state == PlaybinState.PAUSED) playbin.play ();
else if (playbin.state == PlaybinState.PLAYING) playbin.pause (); else if (playbin.state == PlaybinState.PLAYING) playbin.pause ();
}); });
this.on_stop.connect (() => {
playbin.stop ();
});
// TODO: seeking from mpris
// TODO: trigger the seeked signal when applicable
this.notify.connect ((p) => { this.notify.connect ((p) => {
var builder = new VariantBuilder (VariantType.ARRAY); var builder = new VariantBuilder (VariantType.ARRAY);