fix initial setup
This commit is contained in:
parent
770b76e882
commit
0a62dc11a3
2 changed files with 27 additions and 10 deletions
13
src/api.vala
13
src/api.vala
|
@ -19,7 +19,8 @@
|
|||
*/
|
||||
|
||||
errordomain SubsonicError {
|
||||
ERROR
|
||||
BAD_AUTHN,
|
||||
ERROR,
|
||||
}
|
||||
|
||||
public delegate void Wavelet.SongCallback (Song song);
|
||||
|
@ -194,6 +195,10 @@ public class Wavelet.Subsonic : Object {
|
|||
|
||||
public async void ping () throws Error {
|
||||
var msg = new Soup.Message ("GET", @"$(this.url)/rest/ping?f=json&$(this.parameters)");
|
||||
if (msg == null) {
|
||||
throw new SubsonicError.BAD_AUTHN ("Bad message");
|
||||
}
|
||||
|
||||
var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null);
|
||||
assert (msg.get_status () == Soup.Status.OK);
|
||||
|
||||
|
@ -206,6 +211,8 @@ public class Wavelet.Subsonic : Object {
|
|||
|
||||
public async void scrobble (string id) throws Error {
|
||||
var msg = new Soup.Message ("GET", @"$(this.url)/rest/scrobble?id=$(Uri.escape_string (id))&f=json&$(this.parameters)");
|
||||
assert (msg != null);
|
||||
|
||||
var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null);
|
||||
assert (msg.get_status () == Soup.Status.OK);
|
||||
|
||||
|
@ -225,6 +232,8 @@ public class Wavelet.Subsonic : Object {
|
|||
}
|
||||
|
||||
var msg = new Soup.Message("GET", @"$(this.url)/rest/getRandomSongs?$(str_parameters)size=500&f=json&$(this.parameters)");
|
||||
assert (msg != null);
|
||||
|
||||
var bytes = yield this.session.send_and_read_async (msg, Priority.DEFAULT, null);
|
||||
assert (msg.get_status () == Soup.Status.OK);
|
||||
|
||||
|
@ -256,6 +265,8 @@ public class Wavelet.Subsonic : Object {
|
|||
|
||||
public async Gdk.Pixbuf cover_art (string id, int size, Cancellable cancellable) throws Error {
|
||||
var msg = new Soup.Message("GET", this.cover_art_uri (id, size));
|
||||
assert (msg != null);
|
||||
|
||||
var stream = yield this.session.send_async (msg, Priority.DEFAULT, cancellable);
|
||||
assert (msg.get_status () == Soup.Status.OK);
|
||||
return yield new Gdk.Pixbuf.from_stream_async (stream, cancellable);
|
||||
|
|
|
@ -89,18 +89,24 @@ class Playbin : Object {
|
|||
string? next_uri = null;
|
||||
|
||||
this.next_uri_lock.lock ();
|
||||
if (this.next_uri != (string) this.playbin.current_uri) {
|
||||
print("%s\n", this.next_uri);
|
||||
print("%s\n", (string) this.playbin.current_uri);
|
||||
next_uri = this.next_uri;
|
||||
|
||||
if (next_uri != (string) this.playbin.current_uri) {
|
||||
this.next_uri_lock.unlock ();
|
||||
// WHOOPS! didn't actually switch to the track the play queue wanted
|
||||
// FIXME as it arises
|
||||
assert (false);
|
||||
}
|
||||
// we can still fix this though
|
||||
assert (next_uri != null);
|
||||
this.playbin.set_state (Gst.State.READY);
|
||||
this.playbin.uri = next_uri;
|
||||
this.playbin.set_state (Gst.State.PLAYING);
|
||||
// no one will ever know
|
||||
} else {
|
||||
this.next_uri = null;
|
||||
this.next_uri_lock.unlock ();
|
||||
|
||||
this.stream_started ();
|
||||
}
|
||||
}
|
||||
|
||||
if (Gst.MessageType.EOS in message.type) {
|
||||
string next_uri;
|
||||
|
|
Loading…
Reference in a new issue