Compare commits
No commits in common. "8e5ac49417b98cac01fa9dd395fdff03d88707f5" and "efc639367bb20984ab65d06540ce543e38c792b2" have entirely different histories.
8e5ac49417
...
efc639367b
2 changed files with 5 additions and 20 deletions
|
@ -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 (ObjectPath track_id, int64 position);
|
internal signal void on_set_position (string 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 (ObjectPath track_id, int64 position) throws Error { this.on_set_position (track_id, position); }
|
public void set_position (string 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);
|
||||||
|
@ -72,8 +72,6 @@ class MprisPlayer : Object {
|
||||||
[CCode (notify = false)]
|
[CCode (notify = false)]
|
||||||
public bool can_control { get { return true; } }
|
public bool can_control { get { return true; } }
|
||||||
|
|
||||||
internal Subsonic.Client api { get; set; }
|
|
||||||
|
|
||||||
internal MprisPlayer (DBusConnection conn, Playbin playbin) {
|
internal MprisPlayer (DBusConnection conn, Playbin playbin) {
|
||||||
playbin.bind_property (
|
playbin.bind_property (
|
||||||
"state",
|
"state",
|
||||||
|
@ -130,7 +128,7 @@ class MprisPlayer : Object {
|
||||||
var metadata = new HashTable<string, Variant> (null, null);
|
var metadata = new HashTable<string, Variant> (null, null);
|
||||||
metadata["mpris:trackid"] = new ObjectPath (@"/eu/callcc/audrey/track/$(song.id)");
|
metadata["mpris:trackid"] = new ObjectPath (@"/eu/callcc/audrey/track/$(song.id)");
|
||||||
metadata["mpris:length"] = (int64) song.duration * 1000000;
|
metadata["mpris:length"] = (int64) song.duration * 1000000;
|
||||||
if (this.api != null) metadata["mpris:artUrl"] = this.api.cover_art_uri (song.id);
|
// TODO: metadata["mpris:artUrl"] =
|
||||||
metadata["xesam:album"] = song.album;
|
metadata["xesam:album"] = song.album;
|
||||||
metadata["xesam:artist"] = new string[] {song.artist};
|
metadata["xesam:artist"] = new string[] {song.artist};
|
||||||
if (song.genre != null) metadata["xesam:genre"] = song.genre;
|
if (song.genre != null) metadata["xesam:genre"] = song.genre;
|
||||||
|
@ -154,12 +152,6 @@ 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);
|
||||||
|
|
|
@ -29,9 +29,6 @@ class Ui.Window : Adw.ApplicationWindow {
|
||||||
Object (application: app);
|
Object (application: app);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Mpris mpris;
|
|
||||||
private MprisPlayer mpris_player;
|
|
||||||
|
|
||||||
private void now_playing (Subsonic.Song song) {
|
private void now_playing (Subsonic.Song song) {
|
||||||
this.song = song;
|
this.song = song;
|
||||||
// api.scrobble.begin (this.song.id); TODO
|
// api.scrobble.begin (this.song.id); TODO
|
||||||
|
@ -65,11 +62,8 @@ class Ui.Window : Adw.ApplicationWindow {
|
||||||
BusNameOwnerFlags.NONE,
|
BusNameOwnerFlags.NONE,
|
||||||
(conn) => {
|
(conn) => {
|
||||||
try {
|
try {
|
||||||
this.mpris = new Mpris (this);
|
conn.register_object ("/org/mpris/MediaPlayer2", new Mpris (this));
|
||||||
this.mpris_player = new MprisPlayer (conn, this.playbin);
|
conn.register_object ("/org/mpris/MediaPlayer2", new MprisPlayer (conn, this.playbin));
|
||||||
|
|
||||||
conn.register_object ("/org/mpris/MediaPlayer2", this.mpris);
|
|
||||||
conn.register_object ("/org/mpris/MediaPlayer2", this.mpris_player);
|
|
||||||
} catch (IOError e) {
|
} catch (IOError e) {
|
||||||
error ("could not register dbus service: %s", e.message);
|
error ("could not register dbus service: %s", e.message);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +76,6 @@ class Ui.Window : Adw.ApplicationWindow {
|
||||||
this.setup.connected.connect ((api) => {
|
this.setup.connected.connect ((api) => {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.playbin.api = api;
|
this.playbin.api = api;
|
||||||
this.mpris_player.api = api;
|
|
||||||
this.can_click_shuffle_all = true;
|
this.can_click_shuffle_all = true;
|
||||||
});
|
});
|
||||||
this.setup.load ();
|
this.setup.load ();
|
||||||
|
|
Loading…
Reference in a new issue