本文整理汇总了Java中com.sedmelluq.discord.lavaplayer.track.AudioTrack.setPosition方法的典型用法代码示例。如果您正苦于以下问题:Java AudioTrack.setPosition方法的具体用法?Java AudioTrack.setPosition怎么用?Java AudioTrack.setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sedmelluq.discord.lavaplayer.track.AudioTrack
的用法示例。
在下文中一共展示了AudioTrack.setPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
if(!AudioPlayerThread.isPlaying()) {
channel.sendMessage(author.getAsMention() + " ``Currently I'm not playing.``").queue();
return;
}
int seconds;
if(arg == null) {
seconds = 10;
} else {
try {
seconds = Integer.parseInt(arg);
if(seconds == 0) {
throw new NumberFormatException();
}
} catch(NumberFormatException e) {
channel.sendMessage(author.getAsMention() + " ``Invalid number``").queue();
return;
}
}
AudioTrack track = AudioPlayerThread.getMusicManager().player.getPlayingTrack();
track.setPosition(track.getPosition() + (1000*seconds)); // Lavaplayer handles values < 0 or > track length
}
示例2: onNodeChange
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
/**
* Invoked by {@link Link} to make sure we keep playing music on the new node
*/
// Used when we are moved to a new socket
public void onNodeChange() {
if (getPlayingTrack() != null) {
AudioTrack track = getPlayingTrack();
track.setPosition(getTrackPosition());
playTrack(track);
}
}
示例3: 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();
}