本文整理汇总了Java中com.sedmelluq.discord.lavaplayer.track.AudioTrack.getDuration方法的典型用法代码示例。如果您正苦于以下问题:Java AudioTrack.getDuration方法的具体用法?Java AudioTrack.getDuration怎么用?Java AudioTrack.getDuration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sedmelluq.discord.lavaplayer.track.AudioTrack
的用法示例。
在下文中一共展示了AudioTrack.getDuration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInternal
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
@Override
protected boolean doInternal(MessageReceivedEvent message, TrackRequest request, long millis) {
AudioTrack track = request.getTrack();
long duration = track.getDuration();
long position = track.getPosition();
millis = Math.min(duration - position, millis);
if (playerService.getInstance(message.getGuild()).seek(position + millis)) {
messageManager.onMessage(message.getChannel(), "discord.command.audio.forward",
messageManager.getTitle(track.getInfo()), CommonUtils.formatDuration(millis));
request.setResetMessage(true);
}
return ok(message);
}
示例2: doInternal
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
@Override
protected boolean doInternal(MessageReceivedEvent message, TrackRequest request, long millis) {
AudioTrack track = request.getTrack();
long duration = track.getDuration();
millis = Math.min(duration, millis);
if (playerService.getInstance(message.getGuild()).seek(millis)) {
messageManager.onMessage(message.getChannel(), "discord.command.audio.seek",
messageManager.getTitle(track.getInfo()), CommonUtils.formatDuration(millis));
request.setResetMessage(true);
}
return true;
}
示例3: isSongTooLong
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
public static boolean isSongTooLong(AudioTrack track) {
return track.getDuration() >= MAX_DURATION * 1000;
}
示例4: execute
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
public void execute(GuildMessageReceivedEvent e, String query) {
final AudioHandler player = JukeBot.getPlayer(e.getGuild().getAudioManager());
final AudioTrack currentTrack = player.player.getPlayingTrack();
if (!player.isPlaying()) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("No playback activity")
.setDescription("There's nothing playing.")
.build()
).queue();
return;
}
if (!permissions.isElevatedUser(e.getMember(), true)) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("Permission Error")
.setDescription("You need to be a DJ")
.build()
).queue();
return;
}
if (!currentTrack.isSeekable()) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("Unable to Seek")
.setDescription("The currently playing track doesn't support seeking.")
.build()
).queue();
return;
}
int forwardTime = Helpers.parseNumber(query, 10) * 1000;
if (currentTrack.getPosition() + forwardTime >= currentTrack.getDuration()) {
player.playNext();
return;
}
currentTrack.setPosition(currentTrack.getPosition() + forwardTime);
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("Track Seeking")
.setDescription("The current track has been moved to **" + Helpers.fTime(currentTrack.getPosition()) + "**")
.build()
).queue();
}