use of com.sedmelluq.discord.lavaplayer.tools.FriendlyException in project lavaplayer by sedmelluq.
the class RemoteNodeProcessor method handleTrackStartResponse.
private void handleTrackStartResponse(TrackStartResponseMessage message) {
if (message.success) {
log.debug("Successful start confirmation from node {} for executor {}.", nodeAddress, message.executorId);
} else {
RemoteAudioTrackExecutor executor = playingTracks.get(message.executorId);
if (executor != null) {
executor.dispatchException(new FriendlyException("Remote machine failed to start track: " + message.failureReason, SUSPICIOUS, null));
executor.stop();
} else {
log.debug("Received failed track start for an already stopped executor {} from node {}.", message.executorId, nodeAddress);
}
}
}
use of com.sedmelluq.discord.lavaplayer.tools.FriendlyException in project lavaplayer by sedmelluq.
the class HttpAudioSourceManager method detectContainerWithClient.
private MediaContainerDetectionResult detectContainerWithClient(HttpInterface httpInterface, AudioReference reference) throws IOException {
try (PersistentHttpStream inputStream = new PersistentHttpStream(httpInterface, new URI(reference.identifier), Units.CONTENT_LENGTH_UNKNOWN)) {
int statusCode = inputStream.checkStatusCode();
String redirectUrl = HttpClientTools.getRedirectLocation(reference.identifier, inputStream.getCurrentResponse());
if (redirectUrl != null) {
return refer(null, new AudioReference(redirectUrl, null));
} else if (statusCode == HttpStatus.SC_NOT_FOUND) {
return null;
} else if (!HttpClientTools.isSuccessWithContent(statusCode)) {
throw new FriendlyException("That URL is not playable.", COMMON, new IllegalStateException("Status code " + statusCode));
}
MediaContainerHints hints = MediaContainerHints.from(getHeaderValue(inputStream.getCurrentResponse(), "Content-Type"), null);
return new MediaContainerDetection(containerRegistry, reference, inputStream, hints).detectContainer();
} catch (URISyntaxException e) {
throw new FriendlyException("Not a valid URL.", COMMON, e);
}
}
use of com.sedmelluq.discord.lavaplayer.tools.FriendlyException in project lavaplayer by sedmelluq.
the class LocalAudioSourceManager method detectContainerForFile.
private MediaContainerDetectionResult detectContainerForFile(AudioReference reference, File file) {
try (LocalSeekableInputStream inputStream = new LocalSeekableInputStream(file)) {
int lastDotIndex = file.getName().lastIndexOf('.');
String fileExtension = lastDotIndex >= 0 ? file.getName().substring(lastDotIndex + 1) : null;
return new MediaContainerDetection(containerRegistry, reference, inputStream, MediaContainerHints.from(null, fileExtension)).detectContainer();
} catch (IOException e) {
throw new FriendlyException("Failed to open file for reading.", SUSPICIOUS, e);
}
}
use of com.sedmelluq.discord.lavaplayer.tools.FriendlyException in project lavaplayer by sedmelluq.
the class AbandonedTrackManager method add.
/**
* Adds a track executor to abandoned tracks. The abandoned track manager will take over managing its lifecycle and
* the caller should not use it any further.
*
* @param executor The executor to register as an abandoned track.
*/
public void add(RemoteAudioTrackExecutor executor) {
if (abandonedExecutors.offer(new AbandonedExecutor(System.currentTimeMillis(), executor))) {
log.debug("{} has been put up for adoption.", executor);
} else {
log.debug("{} has been discarded, adoption queue is full.", executor);
executor.dispatchException(new FriendlyException("Cannot find a node to play the track on.", COMMON, null));
executor.stop();
}
}
use of com.sedmelluq.discord.lavaplayer.tools.FriendlyException in project lavaplayer by sedmelluq.
the class AbandonedTrackManager method shutdown.
/**
* Shut down the abandoned track manager, stopping any tracks.
*/
public void shutdown() {
AbandonedExecutor executor;
while ((executor = abandonedExecutors.poll()) != null) {
executor.executor.dispatchException(new FriendlyException("Node system was shut down.", COMMON, null));
executor.executor.stop();
}
}
Aggregations