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


Java AudioTrack.setPosition方法代码示例

本文整理汇总了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
}
 
开发者ID:Bleuzen,项目名称:Blizcord,代码行数:26,代码来源:Jump.java

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

}
 
开发者ID:Frederikam,项目名称:Lavalink,代码行数:13,代码来源:LavalinkPlayer.java

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

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


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