more changes
This commit is contained in:
parent
bf2edb3073
commit
84696ef1ca
5 changed files with 73 additions and 43 deletions
|
@ -85,6 +85,7 @@ public class Wavelet.Song : Object {
|
||||||
public string album { get; private set; }
|
public string album { get; private set; }
|
||||||
public string artist { get; private set; }
|
public string artist { get; private set; }
|
||||||
public int64 track { get; private set; }
|
public int64 track { get; private set; }
|
||||||
|
public int64 year { get; private set; }
|
||||||
|
|
||||||
public Song (Json.Reader reader) {
|
public Song (Json.Reader reader) {
|
||||||
reader.read_member ("id");
|
reader.read_member ("id");
|
||||||
|
@ -106,6 +107,10 @@ public class Wavelet.Song : Object {
|
||||||
reader.read_member ("track");
|
reader.read_member ("track");
|
||||||
this.track = reader.get_int_value ();
|
this.track = reader.get_int_value ();
|
||||||
reader.end_member ();
|
reader.end_member ();
|
||||||
|
|
||||||
|
reader.read_member ("year");
|
||||||
|
this.year = reader.get_int_value ();
|
||||||
|
reader.end_member ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,38 +63,6 @@ public class Wavelet.Application : Adw.Application {
|
||||||
win.artist_list.set_loading ();
|
win.artist_list.set_loading ();
|
||||||
win.song_list.set_loading ();
|
win.song_list.set_loading ();
|
||||||
|
|
||||||
win.setup.connected.connect ((api) => {
|
|
||||||
win.artist_list.model = api.artist_list;
|
|
||||||
win.song_list.model = api.song_list;
|
|
||||||
|
|
||||||
api.done_reloading.connect (() => {
|
|
||||||
win.artist_list.set_ready ();
|
|
||||||
win.song_list.set_ready ();
|
|
||||||
});
|
|
||||||
//api.reload.begin ();
|
|
||||||
|
|
||||||
win.shuffle_all_tracks.sensitive = true;
|
|
||||||
win.shuffle_all_tracks.activated.connect (() => {
|
|
||||||
win.shuffle_all_tracks.sensitive = false;
|
|
||||||
win.play_queue.clear ();
|
|
||||||
api.get_random_songs.begin (null, (song) => {
|
|
||||||
win.play_queue.queue (song);
|
|
||||||
}, (obj, res) => {
|
|
||||||
api.get_random_songs.end (res);
|
|
||||||
win.shuffle_all_tracks.sensitive = true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
win.play_queue.play_now.connect ((song) => {
|
|
||||||
win.play_position.sensitive = false;
|
|
||||||
|
|
||||||
playbin.set_state (Gst.State.READY);
|
|
||||||
playbin.set ("uri", api.stream_uri (song.id));
|
|
||||||
playbin.set_state (Gst.State.PLAYING);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
win.setup.load (config_db);
|
|
||||||
|
|
||||||
playbin = Gst.ElementFactory.make ("playbin3", null);
|
playbin = Gst.ElementFactory.make ("playbin3", null);
|
||||||
assert (playbin != null);
|
assert (playbin != null);
|
||||||
|
|
||||||
|
@ -143,9 +111,41 @@ public class Wavelet.Application : Adw.Application {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
Signal.connect (playbin, "about-to-finish", () => {
|
var next_queue = new AsyncQueue<string?> ();
|
||||||
print("about to finish\n");
|
|
||||||
}, null);
|
win.setup.connected.connect ((api) => {
|
||||||
|
win.artist_list.model = api.artist_list;
|
||||||
|
win.song_list.model = api.song_list;
|
||||||
|
|
||||||
|
api.done_reloading.connect (() => {
|
||||||
|
win.artist_list.set_ready ();
|
||||||
|
win.song_list.set_ready ();
|
||||||
|
});
|
||||||
|
//api.reload.begin ();
|
||||||
|
|
||||||
|
win.shuffle_all_tracks.sensitive = true;
|
||||||
|
win.shuffle_all_tracks.activated.connect (() => {
|
||||||
|
win.shuffle_all_tracks.sensitive = false;
|
||||||
|
win.play_queue.clear ();
|
||||||
|
api.get_random_songs.begin (null, (song) => {
|
||||||
|
win.play_queue.queue (song);
|
||||||
|
}, (obj, res) => {
|
||||||
|
api.get_random_songs.end (res);
|
||||||
|
win.shuffle_all_tracks.sensitive = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
win.play_queue.play_now.connect ((song) => {
|
||||||
|
win.play_position.sensitive = false;
|
||||||
|
|
||||||
|
playbin.set_state (Gst.State.READY);
|
||||||
|
playbin.set ("uri", api.stream_uri (song.id));
|
||||||
|
playbin.set_state (Gst.State.PLAYING);
|
||||||
|
|
||||||
|
win.song = song;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
win.setup.load (config_db);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_about_action () {
|
private void on_about_action () {
|
||||||
|
|
|
@ -48,12 +48,13 @@ public class Wavelet.PlayQueue : Adw.NavigationPage {
|
||||||
this.songs.append (song);
|
this.songs.append (song);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Song? next () {
|
public void next () {
|
||||||
if (this.current >= this.songs.get_n_items ()) {
|
if (this.current < this.songs.get_n_items ()) {
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
this.current += 1;
|
this.current += 1;
|
||||||
return (Song) this.songs.get_item (this.current);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Song? peek () {
|
||||||
|
return (Song?) this.songs.get_item (this.current+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,13 +113,33 @@ template $WaveletWindow: Adw.ApplicationWindow {
|
||||||
valign: center;
|
valign: center;
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
styles [ "caption-heading" ]
|
||||||
halign: start;
|
halign: start;
|
||||||
label: "Title";
|
label: bind template.song as <$WaveletSong>.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Box {
|
||||||
halign: start;
|
halign: start;
|
||||||
label: "Artist - Album - Year";
|
Label {
|
||||||
|
styles [ "caption" ]
|
||||||
|
label: bind template.song as <$WaveletSong>.artist;
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
styles [ "caption" ]
|
||||||
|
label: " - ";
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
styles [ "caption" ]
|
||||||
|
label: bind template.song as <$WaveletSong>.album;
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
styles [ "caption" ]
|
||||||
|
label: " - ";
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
styles [ "caption" ]
|
||||||
|
label: bind template.song as <$WaveletSong>.year;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Box {
|
Box {
|
||||||
|
@ -128,6 +148,7 @@ template $WaveletWindow: Adw.ApplicationWindow {
|
||||||
|
|
||||||
Label play_position_label {
|
Label play_position_label {
|
||||||
styles [
|
styles [
|
||||||
|
"caption",
|
||||||
"numeric",
|
"numeric",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -148,6 +169,7 @@ template $WaveletWindow: Adw.ApplicationWindow {
|
||||||
|
|
||||||
Label play_duration {
|
Label play_duration {
|
||||||
styles [
|
styles [
|
||||||
|
"caption",
|
||||||
"numeric",
|
"numeric",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ public class Wavelet.Window : Adw.ApplicationWindow {
|
||||||
|
|
||||||
public double volume { get; set; default = 1.0; }
|
public double volume { get; set; default = 1.0; }
|
||||||
|
|
||||||
|
public Song? song { get; set; default = null; }
|
||||||
|
|
||||||
public Window (Gtk.Application app) {
|
public Window (Gtk.Application app) {
|
||||||
Object (application: app);
|
Object (application: app);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue