Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ public void onPlaybackResumed(@NotNull Player player, long trackTime) {
}

@Override
public void onPlaybackFailed(@NotNull Player player, Exception e) {
public void onPlaybackFailed(@NotNull Player player, @NotNull Exception e) {
JsonObject obj = new JsonObject();
obj.addProperty("event", "playbackFailed");
obj.addProperty("exception", e.getMessage());
obj.addProperty("exception", e.getClass().getCanonicalName());
obj.addProperty("message", e.getMessage());
dispatch(obj);
}

Expand Down
22 changes: 10 additions & 12 deletions lib/src/main/java/xyz/gianlu/librespot/core/ApResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,18 @@ private void request(@NotNull String... types) throws IOException {
try (Response response = client.newCall(request).execute()) {
ResponseBody body = response.body();
if (body == null) throw new IOException("No body");
try (Reader reader = body.charStream()) {
JsonObject obj = JsonParser.parseReader(reader).getAsJsonObject();
HashMap<String, List<String>> map = new HashMap<>();
for (String type : types)
map.put(type, getUrls(obj, type));

synchronized (pool) {
pool.putAll(map);
poolReady = true;
pool.notifyAll();
}
JsonObject obj = JsonParser.parseReader(body.charStream()).getAsJsonObject();
HashMap<String, List<String>> map = new HashMap<>();
for (String type : types)
map.put(type, getUrls(obj, type));

LOGGER.info("Loaded aps into pool: " + pool);
synchronized (pool) {
pool.putAll(map);
poolReady = true;
pool.notifyAll();
}

LOGGER.info("Loaded aps into pool: " + pool);
}
}

Expand Down
6 changes: 3 additions & 3 deletions lib/src/main/java/xyz/gianlu/librespot/core/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,13 @@ private void reconnect() {
}

try {
apResolver.refreshPool();

if (conn != null) {
conn.socket.close();
receiver.stop();
conn.socket.close();
}

apResolver.refreshPool();

conn = ConnectionHolder.create(apResolver.getRandomAccesspoint(), inner.conf);
connect();
authenticatePartial(Authentication.LoginCredentials.newBuilder()
Expand Down
6 changes: 3 additions & 3 deletions player/src/main/java/xyz/gianlu/librespot/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ public interface EventsListener {

void onPlaybackResumed(@NotNull Player player, long trackTime);

void onPlaybackFailed(@NotNull Player player, Exception e);
void onPlaybackFailed(@NotNull Player player, @NotNull Exception e);

void onTrackSeeked(@NotNull Player player, long trackTime);

Expand Down Expand Up @@ -1005,7 +1005,7 @@ public void onPlaybackResumed(@NotNull Player player, long trackTime) {
}

@Override
public void onPlaybackFailed(@NotNull Player player, Exception e) {
public void onPlaybackFailed(@NotNull Player player, @NotNull Exception e) {
}

@Override
Expand Down Expand Up @@ -1082,7 +1082,7 @@ void playbackResumed() {
executorService.execute(() -> l.onPlaybackResumed(Player.this, trackTime));
}

void playbackFailed(Exception ex) {
void playbackFailed(@NotNull Exception ex) {
for (EventsListener l : new ArrayList<>(listeners))
executorService.execute(() -> l.onPlaybackFailed(Player.this, ex));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void onPlaybackResumed(@NotNull Player player, long trackTime) {
}

@Override
public void onPlaybackFailed(@NotNull Player player, Exception e) {
public void onPlaybackFailed(@NotNull Player player, @NotNull Exception e) {
exec(conf.onPlaybackFailed, "EXCEPTION=" + e.getClass().getCanonicalName(), "MESSAGE=" + e.getMessage());
}

Expand Down