Search in sources :

Example 16 with AudioTrackInfo

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));
}
Also used : MediaContainerDetectionResult(com.sedmelluq.discord.lavaplayer.container.MediaContainerDetectionResult) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)

Example 17 with AudioTrackInfo

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;
}
Also used : Element(org.jsoup.nodes.Element) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)

Example 18 with AudioTrackInfo

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);
}
Also used : DataInput(java.io.DataInput) DecodedTrackHolder(com.sedmelluq.discord.lavaplayer.track.DecodedTrackHolder) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo) InternalAudioTrack(com.sedmelluq.discord.lavaplayer.track.InternalAudioTrack) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack)

Example 19 with AudioTrackInfo

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();
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) MusixMatch(org.jmusixmatch.MusixMatch) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo) Lyrics(org.jmusixmatch.entity.lyrics.Lyrics) Track(org.jmusixmatch.entity.track.Track) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) MusixMatchException(org.jmusixmatch.MusixMatchException)

Example 20 with AudioTrackInfo

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);
}
Also used : AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)

Aggregations

AudioTrackInfo (com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)22 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)7 MediaContainerDetectionResult (com.sedmelluq.discord.lavaplayer.container.MediaContainerDetectionResult)6 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)6 FriendlyException (com.sedmelluq.discord.lavaplayer.tools.FriendlyException)5 AudioLoadResultHandler (com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler)3 AudioPlaylist (com.sedmelluq.discord.lavaplayer.track.AudioPlaylist)3 JsonBrowser (com.sedmelluq.discord.lavaplayer.tools.JsonBrowser)2 List (java.util.List)2 Optional (java.util.Optional)2 TimeUnit (java.util.concurrent.TimeUnit)2 Slf4j (lombok.extern.slf4j.Slf4j)2 MessageBuilder (net.dv8tion.jda.core.MessageBuilder)2 Message (net.dv8tion.jda.core.entities.Message)2 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)2 MantaroData (net.kodehawa.mantarobot.data.MantaroData)2 DBGuild (net.kodehawa.mantarobot.data.entities.DBGuild)2 GuildData (net.kodehawa.mantarobot.data.entities.helpers.GuildData)2 DiscordUtils (net.kodehawa.mantarobot.utils.DiscordUtils)2 Utils (net.kodehawa.mantarobot.utils.Utils)2