Skip to content

Commit

Permalink
Added support for stopTime.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neuheit committed Jun 18, 2020
1 parent c6c74f6 commit 7a29ad0
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package lavalink.server.io

import com.sedmelluq.discord.lavaplayer.track.TrackMarker
import lavalink.server.player.TrackEndMarkerHandler
import lavalink.server.util.Util
import moe.kyokobot.koe.VoiceServerInfo
import org.json.JSONObject
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.web.socket.WebSocketSession

class WebSocketHandlers(private val contextMap: Map<String, SocketContext>) {

Expand All @@ -24,7 +25,7 @@ class WebSocketHandlers(private val contextMap: Map<String, SocketContext>) {
//discord sometimes send a partial server update missing the endpoint, which can be ignored.
endpoint ?: return

context.getVoiceConnection(guildId).connect(VoiceServerInfo(sessionId, endpoint, token));
context.getVoiceConnection(guildId).connect(VoiceServerInfo(sessionId, endpoint, token))
}

fun play(context: SocketContext, json: JSONObject) {
Expand All @@ -47,6 +48,16 @@ class WebSocketHandlers(private val contextMap: Map<String, SocketContext>) {
player.setVolume(json.getInt("volume"))
}

if (json.has("stopTime")) {

val stopTime = json.getLong("stopTime")
if (stopTime > 0) {
val handler = TrackEndMarkerHandler(player)
val marker = TrackMarker(stopTime, handler)
track.setMarker(marker)
}
}

player.play(track)

val conn = context.getVoiceConnection(player.guildId.toLong())
Expand Down

0 comments on commit 7a29ad0

Please sign in to comment.