Skip to content

Commit 71a9d8a

Browse files
committed
Handle null player_options_override (#254)
1 parent ad1702f commit 71a9d8a

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

lib/src/main/java/xyz/gianlu/librespot/common/ProtoUtils.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,14 @@ public static Player.PlayOrigin convertPlayOrigin(@Nullable PlayOrigin po) {
181181

182182

183183
@NotNull
184-
public static ContextPlayerOptions jsonToPlayerOptions(@NotNull JsonObject obj, @Nullable ContextPlayerOptions old) {
184+
public static ContextPlayerOptions jsonToPlayerOptions(@Nullable JsonObject obj, @Nullable ContextPlayerOptions old) {
185185
ContextPlayerOptions.Builder builder = old == null ? ContextPlayerOptions.newBuilder() : old.toBuilder();
186186

187-
Optional.ofNullable(obj.get("repeating_context")).ifPresent(elm -> builder.setRepeatingContext(elm.getAsBoolean()));
188-
Optional.ofNullable(obj.get("repeating_track")).ifPresent(elm -> builder.setRepeatingTrack(elm.getAsBoolean()));
189-
Optional.ofNullable(obj.get("shuffling_context")).ifPresent(elm -> builder.setShufflingContext(elm.getAsBoolean()));
187+
if (obj != null) {
188+
Optional.ofNullable(obj.get("repeating_context")).ifPresent(elm -> builder.setRepeatingContext(elm.getAsBoolean()));
189+
Optional.ofNullable(obj.get("repeating_track")).ifPresent(elm -> builder.setRepeatingTrack(elm.getAsBoolean()));
190+
Optional.ofNullable(obj.get("shuffling_context")).ifPresent(elm -> builder.setShufflingContext(elm.getAsBoolean()));
191+
}
190192

191193
return builder.build();
192194
}

player/src/main/java/xyz/gianlu/librespot/player/state/DeviceStateHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public static JsonObject getContext(@NotNull JsonObject obj) {
323323
return obj.getAsJsonObject("context");
324324
}
325325

326-
@NotNull
326+
@Nullable
327327
public static JsonObject getPlayerOptionsOverride(@NotNull JsonObject obj) {
328328
return obj.getAsJsonObject("options").getAsJsonObject("player_options_override");
329329
}

0 commit comments

Comments
 (0)