Skip to content

Commit

Permalink
fix websocket crash when seeking and nothing is playing
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Oct 13, 2023
1 parent cb866b3 commit 14c2137
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class WebSocketHandler(

private fun seek(json: JSONObject) {
val player = context.getPlayer(json.getLong("guildId"))
if (!player.isPlaying) {
log.warn("Can't seek when player is not playing anything")
return
}
player.seekTo(json.getLong("position"))
SocketServer.sendPlayerUpdate(context, player)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class PlayerRestHandler(
playerUpdate.position.takeIf { it.isPresent && !playerUpdate.encodedTrack.isPresent && !playerUpdate.identifier.isPresent }
?.let {
if (player.isPlaying) {
player.seekTo(it)
player.seekTo(it.value)
SocketServer.sendPlayerUpdate(context, player)
}
}
Expand Down

0 comments on commit 14c2137

Please sign in to comment.