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


Java MPDAdmin类代码示例

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


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

示例1: toggleOutput

import org.bff.javampd.MPDAdmin; //导入依赖的package包/类
/**
 * Toggle MPD output 
 * @param id the output id
 * @return ok
 */
public static Result toggleOutput(int id, boolean check)
{
	try
	{
		MPD mpd = MpdMonitor.getInstance().getMPD();
		MPDAdmin admin = mpd.getMPDAdmin();
		List<MPDOutput> outputs = (List<MPDOutput>)admin.getOutputs();
		
		if (id < 0 || id >= outputs.size())
			throw new MPDAdminException("Output ID invalid", new IllegalArgumentException());
		
		MPDOutput output = outputs.get(id);
		
		if (check)
			admin.enableOutput(output); else
			admin.disableOutput(output);
	}
	catch (MPDException e)
	{
		Logger.error("MPD error", e);
		flash("error", e.getMessage());
		return notFound(e.getMessage());
	}

	return ok(""); 
}
 
开发者ID:msteiger,项目名称:play-mpc,代码行数:32,代码来源:Application.java

示例2: executePlayerCommand

import org.bff.javampd.MPDAdmin; //导入依赖的package包/类
/**
 * Executes the given <code>playerCommandLine</code> on the MPD. The
 * <code>playerCommandLine</code> is split into it's properties 
 * <code>playerId</code> and <code>playerCommand</code>.
 * 
 * @param playerCommandLine the complete commandLine which gets splitted into
 * it's properties.
 */
private void executePlayerCommand(String playerCommandLine, Object commandParams) {
	String[] commandParts = playerCommandLine.split(":");
	String playerId = commandParts[0];
	String playerCommand = commandParts[1];

	MPD daemon = findMPDInstance(playerId);
	if (daemon == null) {
		// we give that player another chance -> try to reconnect
		reconnect(playerId);
	}
	
	if (daemon != null) {
		PlayerCommandTypeMapping pCommand = null;			
		try {
			pCommand = PlayerCommandTypeMapping.fromString(playerCommand);
			MPDPlayer player = daemon.getMPDPlayer();
			
			switch (pCommand) {
				case PAUSE: player.pause(); break;
				case PLAY: player.play(); break;
				case STOP: player.stop(); break;
				case VOLUME_INCREASE: player.setVolume(player.getVolume() + VOLUME_CHANGE_SIZE); break;
				case VOLUME_DECREASE: player.setVolume(player.getVolume() - VOLUME_CHANGE_SIZE); break;
				case NEXT: player.playNext(); break;
				case PREV: player.playPrev(); break;
				case ENABLE:
				case DISABLE:
					Integer outputId = Integer.valueOf((String) commandParams);
					MPDAdmin admin = daemon.getMPDAdmin();
					MPDOutput output = new MPDOutput(outputId - 1); // internally mpd uses 0-based indexing
					if (pCommand == PlayerCommandTypeMapping.ENABLE) {
						admin.enableOutput(output);
					} else {
						admin.disableOutput(output);
					}
					break;
				case VOLUME: 
					logger.debug("Volume adjustment received: '{}' '{}'", pCommand, commandParams);
					player.setVolume(((PercentType) commandParams).intValue());
					break;

			}
		}
		catch (MPDPlayerException pe) {
			logger.error("error while executing {} command: " + pe.getMessage(), pCommand);
		}
		catch (Exception e) {
			logger.warn("unknow playerCommand '{}'", playerCommand);
		}
	}
	else {
		logger.warn("didn't find player configuration instance for playerId '{}'", playerId);
	}
		
	logger.info("executed commandLine '{}' for player '{}'", playerCommand, playerId);
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:65,代码来源:MpdBinding.java


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