use of net.robinfriedli.aiode.audio.AudioPlayback in project aiode by robinfriedli.
the class PauseCommand method doRun.
@Override
public void doRun() {
Guild guild = getContext().getGuild();
AudioPlayback playback = Aiode.get().getAudioManager().getPlaybackForGuild(guild);
playback.pause();
}
use of net.robinfriedli.aiode.audio.AudioPlayback in project aiode by robinfriedli.
the class PlayCommand method doRun.
@Override
public void doRun() throws Exception {
CommandContext context = getContext();
Guild guild = context.getGuild();
VoiceChannel channel = context.getVoiceChannel();
AudioManager audioManager = Aiode.get().getAudioManager();
MessageChannel messageChannel = getContext().getChannel();
AudioPlayback playbackForGuild = audioManager.getPlaybackForGuild(guild);
playbackForGuild.setCommunicationChannel(messageChannel);
if (getCommandInput().isBlank()) {
if (playbackForGuild.isPaused() || !audioManager.getQueue(guild).isEmpty()) {
audioManager.startOrResumePlayback(guild, channel);
} else {
throw new InvalidCommandException("Queue is empty. Specify a song you want to play.");
}
} else {
super.doRun();
}
}
use of net.robinfriedli.aiode.audio.AudioPlayback in project aiode by robinfriedli.
the class PlayCommand method handleResults.
@Override
protected void handleResults(List<Playable> playables) {
if (playables.isEmpty()) {
throw new NoResultsFoundException("Result is empty!");
}
Guild guild = getContext().getGuild();
VoiceChannel channel = getContext().getVoiceChannel();
AudioManager audioManager = Aiode.get().getAudioManager();
AudioPlayback playback = getContext().getGuildContext().getPlayback();
AudioPlayer audioPlayer = playback.getAudioPlayer();
if (audioPlayer.getPlayingTrack() != null) {
audioPlayer.stopTrack();
}
playback.getAudioQueue().set(playables);
audioManager.startPlayback(guild, channel);
}
use of net.robinfriedli.aiode.audio.AudioPlayback in project aiode by robinfriedli.
the class QueueCommand method handleResults.
@Override
protected void handleResults(List<Playable> playables) {
if (playables.isEmpty()) {
throw new NoResultsFoundException("Result is empty!");
}
AudioPlayback playback = getContext().getGuildContext().getPlayback();
playback.getAudioQueue().add(playables);
}
use of net.robinfriedli.aiode.audio.AudioPlayback in project aiode by robinfriedli.
the class ReverseCommand method doRun.
@Override
public void doRun() {
AudioPlayback playback = Aiode.get().getAudioManager().getPlaybackForGuild(getContext().getGuild());
AudioTrack playingTrack = playback.getAudioPlayer().getPlayingTrack();
if (playingTrack == null) {
throw new InvalidCommandException("No track is being played at the moment");
}
long toReverseMs;
try {
if (argumentSet("minutes")) {
toReverseMs = Integer.parseInt(getCommandInput()) * 60000;
} else {
toReverseMs = Integer.parseInt(getCommandInput()) * 1000;
}
} catch (NumberFormatException e) {
throw new InvalidCommandException("'" + getCommandInput() + "' is not convertible to type integer. " + "Please enter a valid number.");
}
if (toReverseMs <= 0) {
throw new InvalidCommandException("Expected 1 or greater");
}
long newPosition = playback.getCurrentPositionMs() - toReverseMs;
if (newPosition < 0) {
throw new InvalidCommandException("New position less than 0");
}
playback.setPosition(newPosition);
}
Aggregations