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


Java AudioManager类代码示例

本文整理汇总了Java中net.dv8tion.jda.core.managers.AudioManager的典型用法代码示例。如果您正苦于以下问题:Java AudioManager类的具体用法?Java AudioManager怎么用?Java AudioManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AudioManager类属于net.dv8tion.jda.core.managers包,在下文中一共展示了AudioManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: joinChannel

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
public void joinChannel(VoiceChannel targetChannel) throws MessagingException {
    if (targetChannel == null) {
        throw new MessagingException(I18n.get(getGuild()).getString("playerUserNotInChannel"));
    }

    if (!PermissionUtil.checkPermission(targetChannel, targetChannel.getGuild().getSelfMember(), Permission.VOICE_CONNECT)
            && !targetChannel.getMembers().contains(getGuild().getSelfMember())) {
        throw new MessagingException(I18n.get(getGuild()).getString("playerJoinConnectDenied"));
    }

    if (!PermissionUtil.checkPermission(targetChannel, targetChannel.getGuild().getSelfMember(), Permission.VOICE_SPEAK)) {
        throw new MessagingException(I18n.get(getGuild()).getString("playerJoinSpeakDenied"));
    }

    AudioManager manager = getGuild().getAudioManager();

    manager.openAudioConnection(targetChannel);

    log.info("Connected to voice channel " + targetChannel);
}
 
开发者ID:Frederikam,项目名称:GensokyoBot,代码行数:21,代码来源:GuildPlayer.java

示例2: clearItems

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
private void clearItems(AudioManager manager, GuildMusicManager guildMusicManager, long guildId) {
    if (guildMusicManager != null) {
        guildMusicManager.getScheduler().getQueue().clear();
        guildMusicManager.getPlayer().destroy();

        if (guildMusicManager.getLastActiveMessage() != null) {
            MessageFactory.makeInfo(guildMusicManager.getLastActiveMessage(), "The music has ended due to inactivity.").queue();
        }
    }

    AudioHandler.MUSIC_MANAGER.remove(guildId);
    MISSING_LISTENERS.remove(guildId);
    EMPTY_QUEUE.remove(guildId);

    manager.closeAudioConnection();
}
 
开发者ID:avaire,项目名称:avaire,代码行数:17,代码来源:MusicActivityJob.java

示例3: connectToVoiceChannel

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
@CheckReturnValue
public static VoiceConnectStatus connectToVoiceChannel(Message message, boolean moveChannelIfConnected) {
    AudioManager audioManager = message.getGuild().getAudioManager();
    if (!audioManager.isAttemptingToConnect()) {
        VoiceChannel channel = message.getMember().getVoiceState().getChannel();
        if (channel == null) {
            return VoiceConnectStatus.NOT_CONNECTED;
        }

        if (audioManager.isConnected()) {
            if (channel.getIdLong() == audioManager.getConnectedChannel().getIdLong()) {
                return VoiceConnectStatus.CONNECTED;
            }

            if (moveChannelIfConnected) {
                return connectToVoiceChannel(message, channel, audioManager);
            }
            return VoiceConnectStatus.CONNECTED;
        }
        return connectToVoiceChannel(message, channel, audioManager);
    }
    return VoiceConnectStatus.CONNECTED;
}
 
开发者ID:avaire,项目名称:avaire,代码行数:24,代码来源:AudioHandler.java

示例4: getAudioManager

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
@Override
public AudioManager getAudioManager()
{
    if (!api.isAudioEnabled())
        throw new IllegalStateException("Audio is disabled. Cannot retrieve an AudioManager while audio is disabled.");

    final TLongObjectMap<AudioManager> managerMap = api.getAudioManagerMap();
    AudioManager mng = managerMap.get(id);
    if (mng == null)
    {
        // No previous manager found -> create one
        synchronized (managerMap)
        {
            mng = managerMap.get(id);
            if (mng == null)
            {
                mng = new AudioManagerImpl(this);
                managerMap.put(id, mng);
            }
        }
    }
    return mng;
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:24,代码来源:GuildImpl.java

示例5: open

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
public void open(VoiceChannel channel) {
    if (channel == null) {
        return;
    }
    AudioManager manager = guild.getAudioManager();
    if (manager.isConnected()) {
        return;
    }
    manager.openAudioConnection(channel);
    manager.setAutoReconnect(true);
    manager.setSelfMuted(true);
}
 
开发者ID:kacperduras,项目名称:Charrizard,代码行数:13,代码来源:CAudio.java

示例6: close

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
public void close() {
    AudioManager manager = guild.getAudioManager();
    if (!manager.isConnected()) {
        return;
    }
    manager.closeAudioConnection();
}
 
开发者ID:kacperduras,项目名称:Charrizard,代码行数:8,代码来源:CAudio.java

示例7: playSound

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
private boolean playSound(String id, Guild guild, VoiceChannel channel)
{
	// Gets the audio manager, if it's null, sets it to the player.
	AudioManager manager = guild.getAudioManager();
	if (manager.getSendingHandler() == null)
		manager.setSendingHandler(player);
	
	// Gets the file.
	Sound sound = library.getFile(id);
	
	// Tells the sound player to play the file and what to do after it has done so (leave channel)
	player.play(sound.getPath(), () -> leaveChannel(guild, channel));

	return true;
}
 
开发者ID:SegfaultError11,项目名称:WeenieBot,代码行数:16,代码来源:WeenieBot.java

示例8: joinChannel

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
private boolean joinChannel(VoiceChannel channel, Guild guild)
{
	log.info("Attempt to join channel: <" + channel.getName() + ">");
	
	// Gets the audio manager, and opens an audio connection (Connects to the voice channel)
	AudioManager manager = guild.getAudioManager();
	if (manager.isConnected() || manager.isAttemptingToConnect())
	{
		manager.closeAudioConnection();
		manager.openAudioConnection(channel);
	}
	else		
		manager.openAudioConnection(channel);		
	
	// Waits for the connection to occur.
	int iterations = 0;
	while (!manager.isConnected())
	{
		try 
		{
			if (iterations >= MAX_ATTEMPTS)
				break;
		
			Thread.sleep(100);
			iterations++;
		} 
		catch (InterruptedException e) 
		{
			log.warn("Interrupted while attempting to connect to voice channel.");
			return false;
		}
	}
	
	log.info("Successfully joined channel: <" + channel.getName() + ">");
	
	return true;
}
 
开发者ID:SegfaultError11,项目名称:WeenieBot,代码行数:38,代码来源:WeenieBot.java

示例9: leaveChannel

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
private boolean leaveChannel(Guild guild, VoiceChannel channel)
{
	// Gets the audio manager and closes the connection (Leaves the voice channel)
	AudioManager manager = channel.getGuild().getAudioManager();
	manager.closeAudioConnection();
	
	this.isLocked = false;
	
	return true;
}
 
开发者ID:SegfaultError11,项目名称:WeenieBot,代码行数:11,代码来源:WeenieBot.java

示例10: connectToVoiceChat

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
public int connectToVoiceChat(AudioManager manager, Member member) {
    int res = 0;
    if (member.getVoiceState().inVoiceChannel()) {
        manager.openAudioConnection(member.getVoiceState().getChannel());
        getGuildAudioPlayer(manager.getGuild()).scheduler.changeVolume(20);
        res = 1;
    }
    return res;
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:10,代码来源:Music.java

示例11: disconnectFromVoiceChat

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
public int disconnectFromVoiceChat(AudioManager manager) {
    int res = 0;
    if (manager.isConnected()) {
        getGuildAudioPlayer(manager.getGuild()).player.stopTrack();
        getGuildAudioPlayer(manager.getGuild()).scheduler.clearQueue();
        manager.closeAudioConnection();
        res = 1;
    }
    return res;
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:11,代码来源:Music.java

示例12: GuildPlayer

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
@SuppressWarnings("LeakingThisInConstructor")
public GuildPlayer(JDA jda, Guild guild) {
    this.jda = jda;
    this.guildId = guild.getId();
    subscriber = streamCombiner.subscribe();

    AudioManager manager = guild.getAudioManager();
    manager.setSendingHandler(this);
}
 
开发者ID:Frederikam,项目名称:GensokyoBot,代码行数:10,代码来源:GuildPlayer.java

示例13: leaveVoiceChannelRequest

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
public void leaveVoiceChannelRequest(TextChannel channel, boolean silent) {
    AudioManager manager = getGuild().getAudioManager();
    if (!silent) {
        if (manager.getConnectedChannel() == null) {
            channel.sendMessage(I18n.get(getGuild()).getString("playerNotInChannel")).queue();
        } else {
            channel.sendMessage(MessageFormat.format(I18n.get(getGuild()).getString("playerLeftChannel"), getChannel().getName())).queue();
        }
    }
    manager.closeAudioConnection();
    subscriber.unsubscribe();
}
 
开发者ID:Frederikam,项目名称:GensokyoBot,代码行数:13,代码来源:GuildPlayer.java

示例14: connectToVoiceChannel

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
/**
 * Connect the bot to a voice channel
 * @param audioManager The AudioManager of a guild
 * @param voiceChannel The voice channel to connect in.
 */
private static void connectToVoiceChannel(AudioManager audioManager, VoiceChannel voiceChannel) {
    audioManager.setSelfMuted(false);
    if (!audioManager.isConnected() && !audioManager.isAttemptingToConnect()) {
        audioManager.openAudioConnection(voiceChannel);
    }
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:12,代码来源:MusicManager.java

示例15: handleEmptyMusic

import net.dv8tion.jda.core.managers.AudioManager; //导入依赖的package包/类
private void handleEmptyMusic(AudioManager manager, GuildMusicManager guildMusicManager, long guildId) {
    int times = EMPTY_QUEUE.getOrDefault(guildId, 0) + 1;

    if (times <= 4) {
        EMPTY_QUEUE.put(guildId, times);
        return;
    }

    clearItems(manager, guildMusicManager, guildId);
}
 
开发者ID:avaire,项目名称:avaire,代码行数:11,代码来源:MusicActivityJob.java


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