File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
LavalinkServer/src/main/java/lavalink/server/player Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -199,9 +199,10 @@ Server emitted an event. See the client implementation below.
199199/**
200200 * Implementation details:
201201 * The only events extending {@link lavalink.client.player.event.PlayerEvent} produced by the remote server are these:
202- * 1. TrackEndEvent
203- * 2. TrackExceptionEvent
204- * 3. TrackStuckEvent
202+ * 1. TrackStartEvent
203+ * 2. TrackEndEvent
204+ * 3. TrackExceptionEvent
205+ * 4. TrackStuckEvent
205206 * <p >
206207 * The remaining lavaplayer events are caused by client actions, and are therefore not forwarded via WS.
207208 */
@@ -210,6 +211,11 @@ private void handleEvent(JSONObject json) throws IOException {
210211 PlayerEvent event = null ;
211212
212213 switch (json. getString(" type" )) {
214+ case " TrackStartEvent" :
215+ event = new TrackStartEvent (player,
216+ LavalinkUtil . toAudioTrack(json. getString(" track" ))
217+ );
218+ break ;
213219 case " TrackEndEvent" :
214220 event = new TrackEndEvent (player,
215221 LavalinkUtil . toAudioTrack(json. getString(" track" )),
Original file line number Diff line number Diff line change @@ -47,6 +47,22 @@ public class EventEmitter extends AudioEventAdapter {
4747 this .linkPlayer = linkPlayer ;
4848 }
4949
50+ @ Override
51+ public void onTrackStart (AudioPlayer player , AudioTrack track ) {
52+ JSONObject out = new JSONObject ();
53+ out .put ("op" , "event" );
54+ out .put ("type" , "TrackStartEvent" );
55+ out .put ("guildId" , linkPlayer .getGuildId ());
56+
57+ try {
58+ out .put ("track" , Util .toMessage (audioPlayerManager , track ));
59+ } catch (IOException e ) {
60+ out .put ("track" , JSONObject .NULL );
61+ }
62+
63+ linkPlayer .getSocket ().send (out );
64+ }
65+
5066 @ Override
5167 public void onTrackEnd (AudioPlayer player , AudioTrack track , AudioTrackEndReason endReason ) {
5268 JSONObject out = new JSONObject ();
You can’t perform that action at this time.
0 commit comments