当前位置: 首页>>代码示例>>Java>>正文


Java AudioTrackInfo类代码示例

本文整理汇总了Java中com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo的典型用法代码示例。如果您正苦于以下问题:Java AudioTrackInfo类的具体用法?Java AudioTrackInfo怎么用?Java AudioTrackInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AudioTrackInfo类属于com.sedmelluq.discord.lavaplayer.track包,在下文中一共展示了AudioTrackInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: update

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
@Override
public void update() {
    if (MusicCommand.isIdle(guild) || !MusicCommand.existsTrackManager(trackManager)) {
        deleteThis();
        return;
    }
    final AudioTrack track = trackManager.getPlayer().getPlayingTrack();
    final AudioTrackInfo audioTrackInfo = track.getInfo();
    if (audioTrackInfo == null) {
        deleteThis();
        return;
    }
    final AudioQueue queue = trackManager.getAudioQueue();
    final AudioInfo next = queue.getNext();
    message.editMessage(Standard.getMessageEmbed(null, Standard.toBold("LIVE MUSIC INFO:"))
            .addField("Title", audioTrackInfo.title, false)
            .addField("Duration", String.format("`[%s / %s]`", MusicCommand.getTimestamp(track.getPosition()), MusicCommand.getTimestamp(track.getDuration())), false)
            .addField("Author", audioTrackInfo.author, false)
            .addField("Next Track", (next != null ? next.getTrack().getInfo().title : "None"), false)
            .addField("Volume", MusicCommand.getVolume(guild) + "%", false)
            .addField("Status", String.format("%s, %s", MusicCommand.isPaused(guild) ? "Paused" : "Playing", trackManager.getLoopType().getText()), false)
            .build()).queue();
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:24,代码来源:MusicMessageManager.java

示例2: formatTrackName

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
public static String formatTrackName(AudioTrackInfo info) {
	StringBuilder strBuilder = new StringBuilder();
	if("Unknown artist".equals(info.author)) {
		strBuilder.append(info.title);
	} else {
		strBuilder.append(info.author + " - " + info.title);
	}

	if(info.isStream) {
		strBuilder.append(" (Stream)");
	} else {
		strBuilder.append(" (" + FormatUtils.formatShortDuration(info.length) + ")");
	}

	return strBuilder.toString();
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:17,代码来源:FormatUtils.java

示例3: compareTracks

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
private boolean compareTracks(AudioTrack track1, AudioTrack track2) {
    if (Objects.equals(track1, track2)) {
        return true;
    }
    AudioTrackInfo info1 = track1.getInfo();
    AudioTrackInfo info2 = track2.getInfo();
    if (info1 != null && info2 != null) {
        return Objects.equals(info1.uri, info2.uri)
                && Objects.equals(info1.uri, info2.uri)
                && Objects.equals(info1.title, info2.title)
                && Objects.equals(info1.author, info2.author)
                && Objects.equals(info1.identifier, info2.identifier)
                && Objects.equals(info1.length, info2.length)
                && Objects.equals(info1.isStream, info2.isStream);
    }
    return Objects.equals(info1, info1);
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:18,代码来源:ValidationService.java

示例4: encodeTrack

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
@Override
public void encodeTrack(MessageOutput stream, AudioTrack track) throws IOException {
  DataOutput output = stream.startMessage();
  output.write(TRACK_INFO_VERSION);

  AudioTrackInfo trackInfo = track.getInfo();
  output.writeUTF(trackInfo.title);
  output.writeUTF(trackInfo.author);
  output.writeLong(trackInfo.length);
  output.writeUTF(trackInfo.identifier);
  output.writeBoolean(trackInfo.isStream);
  DataFormatTools.writeNullableText(output, trackInfo.uri);

  encodeTrackDetails(track, output);
  output.writeLong(track.getPosition());

  stream.commitMessage(TRACK_INFO_VERSIONED);
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:19,代码来源:DefaultAudioPlayerManager.java

示例5: decodeTrack

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
@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);
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:23,代码来源:DefaultAudioPlayerManager.java

示例6: loadItem

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
@Override
public AudioItem loadItem(DefaultAudioPlayerManager manager, AudioReference reference) {
  String streamName = getChannelIdentifierFromUrl(reference.identifier);
  if (streamName == null) {
    return null;
  }

  JsonBrowser channelInfo = fetchStreamChannelInfo(streamName);

  if (channelInfo == null) {
    return AudioReference.NO_TRACK;
  } else {
    final String displayName = channelInfo.get("display_name").text();
    final String status = channelInfo.get("status").text();

    return new TwitchStreamAudioTrack(new AudioTrackInfo(
        status,
        displayName,
        Long.MAX_VALUE,
        reference.identifier,
        true,
        reference.identifier
    ), this);
  }
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:26,代码来源:TwitchStreamAudioSourceManager.java

示例7: loadTrackFromPageContent

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
private AudioTrack loadTrackFromPageContent(String trackUrl, String content) throws IOException {
  JsonBrowser config = loadConfigJsonFromPageContent(content);

  if (config == null) {
    throw new FriendlyException("Track information not found on the page.", SUSPICIOUS, null);
  }

  return new VimeoAudioTrack(new AudioTrackInfo(
      config.get("clip").get("title").text(),
      config.get("owner").get("display_name").text(),
      (long) (config.get("clip").get("duration").get("raw").as(Double.class) * 1000.0),
      trackUrl,
      false,
      trackUrl
  ), this);
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:17,代码来源:VimeoAudioSourceManager.java

示例8: probe

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
@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
  ));
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:20,代码来源:WavContainerProbe.java

示例9: probe

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
@Override
public MediaContainerDetectionResult probe(AudioReference reference, SeekableInputStream stream) throws IOException {
  if (!checkNextBytes(stream, OGG_PAGE_HEADER)) {
    return null;
  }

  log.debug("Track {} is an OGG stream.", reference.identifier);

  return new MediaContainerDetectionResult(this, new AudioTrackInfo(
      reference.title != null ? reference.title : UNKNOWN_TITLE,
      UNKNOWN_ARTIST,
      Long.MAX_VALUE,
      reference.identifier,
      true,
      reference.identifier
  ));
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:18,代码来源:OggContainerProbe.java

示例10: probe

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
@Override
public MediaContainerDetectionResult probe(AudioReference reference, SeekableInputStream inputStream) throws IOException {
  if (!checkNextBytes(inputStream, EBML_TAG)) {
    return null;
  }

  log.debug("Track {} is a matroska file.", reference.identifier);

  MatroskaStreamingFile file = new MatroskaStreamingFile(inputStream);
  file.readFile();

  if (!hasSupportedAudioTrack(file)) {
    return new MediaContainerDetectionResult(this, "No supported audio tracks present in the file.");
  }

  return new MediaContainerDetectionResult(this, new AudioTrackInfo(UNKNOWN_TITLE, UNKNOWN_ARTIST,
      (long) file.getDuration(), reference.identifier, false, reference.identifier));
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:19,代码来源:MatroskaContainerProbe.java

示例11: probe

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
@Override
public MediaContainerDetectionResult probe(AudioReference reference, SeekableInputStream inputStream) throws IOException {
  AdtsStreamReader reader = new AdtsStreamReader(inputStream);

  if (reader.findPacketHeader(MediaContainerDetection.STREAM_SCAN_DISTANCE) == null) {
    return null;
  }

  log.debug("Track {} is an ADTS stream.", reference.identifier);

  return new MediaContainerDetectionResult(this, new AudioTrackInfo(
      reference.title != null ? reference.title : MediaContainerDetection.UNKNOWN_TITLE,
      MediaContainerDetection.UNKNOWN_ARTIST,
      Long.MAX_VALUE,
      reference.identifier,
      true,
      reference.identifier
  ));
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:20,代码来源:AdtsContainerProbe.java

示例12: probe

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
@Override
public MediaContainerDetectionResult probe(AudioReference reference, SeekableInputStream inputStream) throws IOException {
  if (!checkNextBytes(inputStream, FlacFileLoader.FLAC_CC)) {
    return null;
  }

  log.debug("Track {} is a FLAC file.", reference.identifier);

  FlacTrackInfo trackInfo = new FlacFileLoader(inputStream).parseHeaders();

  return new MediaContainerDetectionResult(this, new AudioTrackInfo(
      defaultOnNull(trackInfo.tags.get(TITLE_TAG), UNKNOWN_TITLE),
      defaultOnNull(trackInfo.tags.get(ARTIST_TAG), UNKNOWN_ARTIST),
      trackInfo.duration,
      reference.identifier,
      false,
      reference.identifier
  ));
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:20,代码来源:FlacContainerProbe.java

示例13: onQueue

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
public void onQueue(MessageChannel sourceChannel, BotContext context, List<TrackRequest> requests, int pageNum) {
    initLocale(sourceChannel);
    final int pageSize = 25;
    List<List<TrackRequest>> parts = Lists.partition(requests, pageSize);
    final int totalPages = parts.size();
    final int offset = (pageNum - 1) * pageSize + 1;

    final long totalDuration = requests.stream()
            .filter(Objects::nonNull)
            .map(TrackRequest::getTrack)
            .filter(Objects::nonNull)
            .mapToLong(AudioTrack::getDuration).sum();

    if (pageNum > totalPages) {
        onQueueError(sourceChannel, "discord.command.audio.queue.list.totalPages", parts.size());
        return;
    }
    List<TrackRequest> pageRequests = parts.get(pageNum - 1);

    EmbedBuilder builder = getQueueMessage();
    for (int i = 0; i < pageRequests.size(); i++) {
        TrackRequest request = pageRequests.get(i);
        AudioTrack track = request.getTrack();
        AudioTrackInfo info = track.getInfo();

        int rowNum = i + offset;
        String title = messageService.getMessage("discord.command.audio.queue.list.entry", rowNum,
                CommonUtils.formatDuration(track.getDuration()), rowNum == 1 ? ":musical_note: " : "",
                getTitle(info), info.uri, request.getMember().getEffectiveName());
        builder.addField(EmbedBuilder.ZERO_WIDTH_SPACE, title, false);
    }
    builder.setFooter(totalPages > 1
            ? messageService.getMessage("discord.command.audio.queue.list.pageFooter",
            pageNum, totalPages, requests.size(), CommonUtils.formatDuration(totalDuration),
            context.getConfig().getPrefix())
            : messageService.getMessage("discord.command.audio.queue.list.footer",
            requests.size(), CommonUtils.formatDuration(totalDuration)), null);
    messageService.sendMessageSilent(sourceChannel::sendMessage, builder.build());
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:40,代码来源:AudioMessageManager.java

示例14: getBasicMessage

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
private EmbedBuilder getBasicMessage(TrackRequest request) {
    AudioTrackInfo info = request.getTrack().getInfo();
    String thumbUrl = getThumbnail(info);

    EmbedBuilder builder = messageService.getBaseEmbed();
    builder.setTitle(getTitle(info), info.uri);
    builder.setAuthor(getArtist(info), info.uri, thumbUrl);
    builder.setThumbnail(thumbUrl);
    builder.setDescription(messageService.getMessage("discord.command.audio.queue.add"));
    return builder;
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:12,代码来源:AudioMessageManager.java

示例15: getThumbnail

import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; //导入依赖的package包/类
private String getThumbnail(AudioTrackInfo info) {
    try {
        URI uri = new URI(info.uri);
        if (uri.getHost().contains("youtube.com") || uri.getHost().contains("youtu.be")) {
            return String.format("https://img.youtube.com/vi/%s/0.jpg", info.identifier);
        }
    } catch (URISyntaxException e) {
        // fall down
    }
    return null;
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:12,代码来源:AudioMessageManager.java


注:本文中的com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。