Compare commits
3 commits
6c12828e31
...
dee32826ec
Author | SHA1 | Date | |
---|---|---|---|
dee32826ec | |||
e1922a4d28 | |||
14053a67a1 |
4 changed files with 31 additions and 6 deletions
|
@ -35,6 +35,7 @@ class Playbin : GLib.Object {
|
||||||
// sent when a new song starts playing
|
// sent when a new song starts playing
|
||||||
// continues: whether the track is a gapless continuation
|
// continues: whether the track is a gapless continuation
|
||||||
public signal void now_playing (bool continues, uint index, Song song);
|
public signal void now_playing (bool continues, uint index, Song song);
|
||||||
|
public signal void stopped ();
|
||||||
|
|
||||||
// the index of the track in the play queue that is currently playing
|
// the index of the track in the play queue that is currently playing
|
||||||
// must equal play queue len iff state is STOPPED
|
// must equal play queue len iff state is STOPPED
|
||||||
|
@ -136,7 +137,8 @@ class Playbin : GLib.Object {
|
||||||
if (this.update_position) {
|
if (this.update_position) {
|
||||||
int64 new_position;
|
int64 new_position;
|
||||||
if (this.playbin.query_position (Gst.Format.TIME, out new_position)) {
|
if (this.playbin.query_position (Gst.Format.TIME, out new_position)) {
|
||||||
this.position = new_position;
|
if (new_position > this.duration) this.position = this.duration;
|
||||||
|
else this.position = new_position;
|
||||||
} else {
|
} else {
|
||||||
this.position = 0;
|
this.position = 0;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +209,7 @@ class Playbin : GLib.Object {
|
||||||
});
|
});
|
||||||
|
|
||||||
bus.message["eos"].connect ((message) => {
|
bus.message["eos"].connect ((message) => {
|
||||||
assert (false); // TODO
|
this.stop ();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,5 +259,9 @@ class Playbin : GLib.Object {
|
||||||
this.playbin.set_state (Gst.State.READY);
|
this.playbin.set_state (Gst.State.READY);
|
||||||
this.state = PlaybinState.STOPPED;
|
this.state = PlaybinState.STOPPED;
|
||||||
this.current_position = this.play_queue.get_n_items ();
|
this.current_position = this.play_queue.get_n_items ();
|
||||||
|
this.stopped ();
|
||||||
|
|
||||||
|
this.position = 0;
|
||||||
|
this.duration = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class PlayQueueSelection : GLib.Object, GLib.ListModel, Gtk.SelectionMode
|
||||||
|
|
||||||
if (this.current_position >= position) {
|
if (this.current_position >= position) {
|
||||||
if (this.current_position < position+removed && added == 0) {
|
if (this.current_position < position+removed && added == 0) {
|
||||||
emit_signal = true;
|
if (position < this.get_n_items ()) emit_signal = true;
|
||||||
this.current_position = position;
|
this.current_position = position;
|
||||||
} else {
|
} else {
|
||||||
this.current_position += added;
|
this.current_position += added;
|
||||||
|
@ -154,6 +154,7 @@ public class PlayQueueSelection : GLib.Object, GLib.ListModel, Gtk.SelectionMode
|
||||||
// GLib.ListModel methods
|
// GLib.ListModel methods
|
||||||
|
|
||||||
Object? get_item (uint position) {
|
Object? get_item (uint position) {
|
||||||
|
if (this.model == null) return null;
|
||||||
return this.model.get_item (position);
|
return this.model.get_item (position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +163,7 @@ public class PlayQueueSelection : GLib.Object, GLib.ListModel, Gtk.SelectionMode
|
||||||
}
|
}
|
||||||
|
|
||||||
uint get_n_items () {
|
uint get_n_items () {
|
||||||
|
if (this.model == null) return 0;
|
||||||
return this.model.get_n_items ();
|
return this.model.get_n_items ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,21 +103,21 @@ template $UiWindow: Adw.ApplicationWindow {
|
||||||
styles [ "heading" ]
|
styles [ "heading" ]
|
||||||
xalign: 0;
|
xalign: 0;
|
||||||
halign: start;
|
halign: start;
|
||||||
label: bind template.song as <$Song>.title;
|
label: bind $song_title (template.song) as <string>;
|
||||||
ellipsize: end;
|
ellipsize: end;
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
styles [ "caption" ]
|
styles [ "caption" ]
|
||||||
xalign: 0;
|
xalign: 0;
|
||||||
label: bind template.song as <$Song>.artist;
|
label: bind $song_artist (template.song) as <string>;
|
||||||
ellipsize: end;
|
ellipsize: end;
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
styles [ "caption" ]
|
styles [ "caption" ]
|
||||||
xalign: 0;
|
xalign: 0;
|
||||||
label: bind template.song as <$Song>.album;
|
label: bind $song_album (template.song) as <string>;
|
||||||
ellipsize: end;
|
ellipsize: end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,7 @@ template $UiWindow: Adw.ApplicationWindow {
|
||||||
name: "seek-scale";
|
name: "seek-scale";
|
||||||
orientation: horizontal;
|
orientation: horizontal;
|
||||||
width-request: 400;
|
width-request: 400;
|
||||||
|
sensitive: bind $playbin_active (template.playbin as <$Playbin>.state as <$PlaybinState>) as <bool>;
|
||||||
|
|
||||||
adjustment: Adjustment {
|
adjustment: Adjustment {
|
||||||
lower: 0;
|
lower: 0;
|
||||||
|
|
|
@ -65,6 +65,10 @@ class Ui.Window : Adw.ApplicationWindow {
|
||||||
api.scrobble.begin (song.id);
|
api.scrobble.begin (song.id);
|
||||||
this.play_queue.selection.playbin_select (position);
|
this.play_queue.selection.playbin_select (position);
|
||||||
});
|
});
|
||||||
|
this.playbin.stopped.connect (() => {
|
||||||
|
this.song = null;
|
||||||
|
this.play_queue.selection.playbin_select (this.play_queue_store.get_n_items ());
|
||||||
|
});
|
||||||
|
|
||||||
this.play_queue.selection.user_selected.connect ((position) => {
|
this.play_queue.selection.user_selected.connect ((position) => {
|
||||||
this.playbin.select_track (position);
|
this.playbin.select_track (position);
|
||||||
|
@ -215,4 +219,16 @@ class Ui.Window : Adw.ApplicationWindow {
|
||||||
if (new_position > this.playbin.duration) new_position = this.playbin.duration;
|
if (new_position > this.playbin.duration) new_position = this.playbin.duration;
|
||||||
this.seek_impl (new_position);
|
this.seek_impl (new_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[GtkCallback] private string song_title (Song? song) {
|
||||||
|
return song == null ? "" : song.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
[GtkCallback] private string song_artist (Song? song) {
|
||||||
|
return song == null ? "" : song.artist;
|
||||||
|
}
|
||||||
|
|
||||||
|
[GtkCallback] private string song_album (Song? song) {
|
||||||
|
return song == null ? "" : song.album;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue