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 artist { get; private set; }
|
||||
public int64 track { get; private set; }
|
||||
public int64 year { get; private set; }
|
||||
|
||||
public Song (Json.Reader reader) {
|
||||
reader.read_member ("id");
|
||||
|
@ -106,6 +107,10 @@ public class Wavelet.Song : Object {
|
|||
reader.read_member ("track");
|
||||
this.track = reader.get_int_value ();
|
||||
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.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);
|
||||
assert (playbin != null);
|
||||
|
||||
|
@ -143,9 +111,41 @@ public class Wavelet.Application : Adw.Application {
|
|||
return true;
|
||||
});
|
||||
|
||||
Signal.connect (playbin, "about-to-finish", () => {
|
||||
print("about to finish\n");
|
||||
}, null);
|
||||
var next_queue = new AsyncQueue<string?> ();
|
||||
|
||||
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 () {
|
||||
|
|
|
@ -48,12 +48,13 @@ public class Wavelet.PlayQueue : Adw.NavigationPage {
|
|||
this.songs.append (song);
|
||||
}
|
||||
|
||||
public Song? next () {
|
||||
if (this.current >= this.songs.get_n_items ()) {
|
||||
return null;
|
||||
} else {
|
||||
public void next () {
|
||||
if (this.current < this.songs.get_n_items ()) {
|
||||
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;
|
||||
|
||||
Label {
|
||||
styles [ "caption-heading" ]
|
||||
halign: start;
|
||||
label: "Title";
|
||||
label: bind template.song as <$WaveletSong>.title;
|
||||
}
|
||||
|
||||
Label {
|
||||
Box {
|
||||
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 {
|
||||
|
@ -128,6 +148,7 @@ template $WaveletWindow: Adw.ApplicationWindow {
|
|||
|
||||
Label play_position_label {
|
||||
styles [
|
||||
"caption",
|
||||
"numeric",
|
||||
]
|
||||
|
||||
|
@ -148,6 +169,7 @@ template $WaveletWindow: Adw.ApplicationWindow {
|
|||
|
||||
Label play_duration {
|
||||
styles [
|
||||
"caption",
|
||||
"numeric",
|
||||
]
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ public class Wavelet.Window : Adw.ApplicationWindow {
|
|||
|
||||
public double volume { get; set; default = 1.0; }
|
||||
|
||||
public Song? song { get; set; default = null; }
|
||||
|
||||
public Window (Gtk.Application app) {
|
||||
Object (application: app);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue