本文整理汇总了Java中com.sedmelluq.discord.lavaplayer.track.AudioTrack.getUserData方法的典型用法代码示例。如果您正苦于以下问题:Java AudioTrack.getUserData方法的具体用法?Java AudioTrack.getUserData怎么用?Java AudioTrack.getUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sedmelluq.discord.lavaplayer.track.AudioTrack
的用法示例。
在下文中一共展示了AudioTrack.getUserData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playTrack
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
@Override
public void playTrack(AudioTrack track) {
try {
position = track.getPosition();
TrackData trackData = track.getUserData(TrackData.class);
JSONObject json = new JSONObject();
json.put("op", "play");
json.put("guildId", link.getGuildId());
json.put("track", LavalinkUtil.toMessage(track));
json.put("startTime", position);
if (trackData != null) {
json.put("startTime", trackData.startPos);
json.put("endTime", trackData.endPos);
}
json.put("pause", paused);
link.getNode(true).send(json.toString());
updateTime = System.currentTimeMillis();
this.track = track;
emitEvent(new TrackStartEvent(this, track));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例2: onTrackEnd
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
@Override
public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) {
if (track == null) {
return;
}
PlaybackInstance instance = track.getUserData(PlaybackInstance.class);
if (instance == null) {
return;
}
TrackRequest current = instance.getCurrent();
if (current != null) {
messageManager.onTrackEnd(current);
}
switch (endReason) {
case STOPPED:
case CLEANUP:
break;
case REPLACED:
return;
case FINISHED:
case LOAD_FAILED:
if (instance.playNext()) {
return;
}
if (current != null) {
messageManager.onQueueEnd(current);
}
break;
}
// execute instance reset out of current thread
taskExecutor.execute(instance::reset);
}
示例3: onPlayerResume
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
@Override
public void onPlayerResume(AudioPlayer player) {
AudioTrack track = player.getPlayingTrack();
if (track != null) {
PlaybackInstance instance = track.getUserData(PlaybackInstance.class);
if (instance.isActive()) {
messageManager.onTrackResume(instance.getCurrent());
}
}
}
示例4: serialize
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
@Override
public JsonElement serialize(AudioTrack src, Type typeOfSrc, JsonSerializationContext context) {
AudioTrackInfo info = src.getInfo();
// Get meta data
AudioTrackMetaData metaData = (AudioTrackMetaData) src.getUserData();
// Parse votes to json array
JsonArray votes = new JsonArray();
for (Map.Entry<Integer, Byte> entry : metaData.getVotes().entrySet()) {
JsonObject vote = new JsonObject();
vote.addProperty(entry.getKey().toString(), entry.getValue());
votes.add(vote);
}
JsonObject jsonTrack = new JsonObject();
jsonTrack.addProperty("id", metaData.getTrackID());
jsonTrack.addProperty("uri", info.uri);
jsonTrack.addProperty("userID", metaData.getUserID());
jsonTrack.addProperty("userName", metaData.getUserName());
jsonTrack.addProperty("title", info.title);
jsonTrack.add("voters", votes);
jsonTrack.addProperty("votes", metaData.getVoteCount());
jsonTrack.addProperty("length", info.length);
jsonTrack.addProperty("position", src.getPosition());
return jsonTrack;
}
示例5: execute
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
public void execute(GuildMessageReceivedEvent e, String query) {
final AudioHandler player = JukeBot.getPlayer(e.getGuild().getAudioManager());
if (player.getQueue().isEmpty()) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("Queue is empty")
.setDescription("There is nothing to unqueue.")
.build()
).queue();
return;
}
if (query.length() == 0) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("Specify song position")
.setDescription("You need to specify the position of the song in the queue.")
.build()
).queue();
return;
}
final int selected = Helpers.parseNumber(query, 0);
if (selected < 1 || selected > player.getQueue().size()) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("Invalid position specified")
.setDescription("You need to specify a valid number.")
.build()
).queue();
return;
}
final AudioTrack selectedTrack = player.getQueue().get(selected - 1);
if ((long) selectedTrack.getUserData() != e.getAuthor().getIdLong() && !permissions.isElevatedUser(e.getMember(), false)) {
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("Cannot unqueue track")
.setDescription("You need to have the DJ role to unqueue other users' tracks.")
.build()
).queue();
return;
}
player.getQueue().remove(selected - 1);
e.getChannel().sendMessage(new EmbedBuilder()
.setColor(JukeBot.embedColour)
.setTitle("Track Unqueued")
.setDescription("Removed **" + selectedTrack.getInfo().title + "** from the queue.")
.build()
).queue();
}
示例6: isTrackRequester
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
public boolean isTrackRequester(AudioTrack track, long requester) {
return (long) track.getUserData() == requester;
}
示例7: onTrackStart
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
@Override
public void onTrackStart(AudioPlayer player, AudioTrack track) {
PlaybackInstance instance = track.getUserData(PlaybackInstance.class);
messageManager.onTrackStart(instance.getCurrent());
}