use of com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo in project lavaplayer by sedmelluq.
the class WavContainerProbe method probe.
@Override
public MediaContainerDetectionResult probe(AudioReference reference, SeekableInputStream inputStream) throws IOException {
if (!checkNextBytes(inputStream, WAV_RIFF_HEADER)) {
return null;
}
log.debug("Track {} is a WAV file.", reference.identifier);
WavFileInfo fileInfo = new WavFileLoader(inputStream).parseHeaders();
return new MediaContainerDetectionResult(this, new AudioTrackInfo(defaultOnNull(reference.title, UNKNOWN_TITLE), UNKNOWN_ARTIST, fileInfo.getDuration(), reference.identifier, false, reference.identifier));
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo in project lavaplayer by sedmelluq.
the class NicoAudioSourceManager method extractTrackFromXml.
private AudioTrack extractTrackFromXml(String videoId, Document document) {
for (Element element : document.select(":root > thumb")) {
String uploader = element.select("user_nickname").first().text();
String title = element.select("title").first().text();
long duration = DataFormatTools.durationTextToMillis(element.select("length").first().text());
return new NicoAudioTrack(new AudioTrackInfo(title, uploader, duration, videoId, false, getWatchUrl(videoId)), this);
}
return null;
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo in project lavaplayer by sedmelluq.
the class DefaultAudioPlayerManager method decodeTrack.
@Override
public DecodedTrackHolder decodeTrack(MessageInput stream) throws IOException {
DataInput input = stream.nextMessage();
if (input == null) {
return null;
}
int version = (stream.getMessageFlags() & TRACK_INFO_VERSIONED) != 0 ? (input.readByte() & 0xFF) : 1;
AudioTrackInfo trackInfo = new AudioTrackInfo(input.readUTF(), input.readUTF(), input.readLong(), input.readUTF(), input.readBoolean(), version >= 2 ? DataFormatTools.readNullableText(input) : null);
AudioTrack track = decodeTrackDetails(trackInfo, input);
long position = input.readLong();
if (track != null) {
track.setPosition(position);
}
stream.skipRemainingBytes();
return new DecodedTrackHolder(track);
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo in project Rubicon by Rubicon-Bot.
the class MusicManager method executeLyrics.
public Message executeLyrics() {
if (!isBotInVoiceChannel())
return message(error("Error!", "Bot is not in a voice channel."));
VoiceChannel channel = getBotsVoiceChannel();
if (parsedCommandInvocation.getMember().getVoiceState().getChannel() != channel)
return message(error("Error!", "You have to be in the same voice channel as the bot."));
if (getCurrentMusicManager().getPlayer().getPlayingTrack() == null) {
return message(error("Error!", "Bot is playing nothing."));
}
MusixMatch musixMatch = new MusixMatch(Info.MUSIXMATCH_KEY);
AudioTrackInfo info = this.getCurrentTrack().getInfo();
Track track;
Lyrics lyrics;
try {
track = musixMatch.getMatchingTrack(info.title, info.author);
lyrics = musixMatch.getLyrics(track.getTrack().getTrackId());
} catch (MusixMatchException e) {
return new MessageBuilder().setEmbed(EmbedUtil.error("No lyrics found", "There are no lyrics of the current song on Musixmatch").build()).build();
}
EmbedBuilder lyricsEmbed = new EmbedBuilder();
lyricsEmbed.setColor(Colors.COLOR_PREMIUM);
lyricsEmbed.setTitle("Lyrics of `" + track.getTrack().getTrackName() + "`", track.getTrack().getTrackShareUrl());
lyricsEmbed.setFooter(lyrics.getLyricsCopyright(), null);
lyricsEmbed.setDescription(lyrics.getLyricsBody());
return new MessageBuilder().setEmbed(lyricsEmbed.build()).build();
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo in project Ardent by adamint.
the class Playing method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
GuildMusicManager manager = getGuildAudioPlayer(guild, channel);
ArdentMusicManager ardentMusicManager = manager.scheduler.manager;
ArdentTrack nowPlaying = ardentMusicManager.getCurrentlyPlaying();
if (nowPlaying != null) {
AudioTrack track = nowPlaying.getTrack();
AudioTrackInfo info = track.getInfo();
StringBuilder sb = new StringBuilder();
String queuedBy = "queued by";
sb.append(info.title + ": " + info.author + " " + getCurrentTime(track) + "\n *" + queuedBy + " " + UserUtils.getUserById(nowPlaying.getAuthor()).getName() + "* - [" + nowPlaying.getVotedToSkip().size() + " / " + Math.round(guild.getAudioManager().getConnectedChannel().getMembers().size() / 2) + "] votes to skip");
sendTranslatedMessage(sb.toString(), sendTo(channel, guild), user);
} else
sendTranslatedMessage("I'm not playing anything right now!", channel, user);
}
Aggregations