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


Java AudioTrack.getUserData方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Frederikam,项目名称:Lavalink,代码行数:25,代码来源:LavalinkPlayer.java

示例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);
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:33,代码来源:PlayerServiceImpl.java

示例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());
        }
    }
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:11,代码来源:PlayerServiceImpl.java

示例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;
}
 
开发者ID:VSETH-GECO,项目名称:BASS,代码行数:29,代码来源:AudioTrackSerializer.java

示例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();

    }
 
开发者ID:Devoxin,项目名称:JukeBot,代码行数:59,代码来源:Unqueue.java

示例6: isTrackRequester

import com.sedmelluq.discord.lavaplayer.track.AudioTrack; //导入方法依赖的package包/类
public boolean isTrackRequester(AudioTrack track, long requester) {
    return (long) track.getUserData() == requester;
}
 
开发者ID:Devoxin,项目名称:JukeBot,代码行数:4,代码来源:Permissions.java

示例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());
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:6,代码来源:PlayerServiceImpl.java


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