package de.yannicpunktdee.yoshibot.audio;

import com.sedmelluq.discord.lavaplayer.player.event.AudioEvent;
import com.sedmelluq.discord.lavaplayer.player.event.AudioEventListener;

import net.dv8tion.jda.api.managers.AudioManager;

public class AudioPlayerListener implements AudioEventListener {
	
	private AudioManager audioManager;
	
	
	public AudioPlayerListener(AudioManager audioManager) {
		this.audioManager = audioManager;
	}

	@Override
	public void onEvent(AudioEvent event) {
		if(event.player.getPlayingTrack() == null) {
			event.player.stopTrack();
			audioManager.closeAudioConnection();
		}
	}

}
