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


Java MPDStandAloneMonitor类代码示例

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


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

示例1: disconnect

import org.bff.javampd.monitor.MPDStandAloneMonitor; //导入依赖的package包/类
/**
 * Disconnects the player <code>playerId</code>
 * 
 * @param playerId the id of the player to disconnect from
 */
private void disconnect(String playerId) {
       try {
		MpdPlayerConfig playerConfig = playerConfigCache.get(playerId);
		MPDStandAloneMonitor monitor = playerConfig.monitor;
		if (monitor != null) {
			monitor.stop();
		}
       	MPD mpd = playerConfig.instance;
       	if (mpd != null) {
       		mpd.close();
       	}
	} catch (MPDConnectionException ce) {
		logger.warn("couldn't disconnect player {}", playerId);
	} catch (MPDResponseException re) {
		logger.warn("received response error {}", re.getLocalizedMessage());
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:23,代码来源:MpdBinding.java

示例2: disconnect

import org.bff.javampd.monitor.MPDStandAloneMonitor; //导入依赖的package包/类
/**
 * Disconnects the player <code>playerId</code>
 *
 * @param playerId the id of the player to disconnect
 */
private void disconnect(String playerId) {
    try {
        MpdPlayerConfig playerConfig = playerConfigCache.get(playerId);
        MPDStandAloneMonitor monitor = playerConfig.monitor;
        if (monitor != null) {
            monitor.stop();
        }
        MPD mpd = playerConfig.instance;
        if (mpd != null) {
            mpd.close();
        }
    } catch (MPDConnectionException ce) {
        logger.warn("Couldn't disconnect player '{}'", playerId);
    } catch (MPDResponseException re) {
        logger.warn("Received response error: {}", re.getLocalizedMessage());
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:23,代码来源:MpdBinding.java

示例3: MpdMonitor

import org.bff.javampd.monitor.MPDStandAloneMonitor; //导入依赖的package包/类
private MpdMonitor() throws UnknownHostException, MPDConnectionException
{
	Configuration config = Play.application().configuration();

	String hostname = config.getString("mpd.hostname");
	int port = config.getInt("mpd.port");
	String password = config.getString("mpd.password");
	int timeout = config.getInt("mpd.timeout", 10) * 1000;
	
	Logger.info("Connecting to MPD");
	
	mpd = new MPD(hostname, port, password, timeout);
	monitor = new MPDStandAloneMonitor(mpd, 1000);
	
	thread = new Thread(monitor);
	thread.start();
}
 
开发者ID:msteiger,项目名称:play-mpc,代码行数:18,代码来源:MpdMonitor.java

示例4: connect

import org.bff.javampd.monitor.MPDStandAloneMonitor; //导入依赖的package包/类
/**
 * Connects the player <code>playerId</code> to the given <code>host</code>
 * and <code>port</code> and registers this binding as MPD-Event listener.
 * 
 * @param playerId
 * @param host
 * @param port
 */
private void connect(final String playerId) {
	MpdPlayerConfig config = null;
	try {
    	
    	config = playerConfigCache.get(playerId);
    	if (config != null && config.instance == null) {
    		
    		MPD mpd = new MPD(config.host, config.port, config.password, CONNECTION_TIMEOUT);
    		
    	    MPDStandAloneMonitor mpdStandAloneMonitor = new MPDStandAloneMonitor(mpd, 500);
    	    	mpdStandAloneMonitor.addVolumeChangeListener(this);
    	    	mpdStandAloneMonitor.addPlayerChangeListener(this);
    	    	mpdStandAloneMonitor.addTrackPositionChangeListener(this);	    	    	
    	    	
    	    	final MpdBinding self = this; // 'this' glue for the inner anon instance
    	    	mpdStandAloneMonitor.addOutputChangeListener(new OutputChangeListener() {
    	    		
					@Override
					public void outputChanged(OutputChangeEvent e) {
						// We have to 'wrap' the OutputChangeEvent listener
						// callback and add the playerId so we know which 
						// player generated the event. There's not enough 
						// info on just the OutputChangeEvent to derive 
						// the source player. This 'workaround' is necessary 
						// to support output control on multiple MPD players.
						self.outputChanged(playerId, e);
						
					}
					
				});
    	    	
    	    Thread monitorThread = new Thread(
    	    	mpdStandAloneMonitor, "MPD Monitor (player:" + playerId + ")");
    	    monitorThread.start();
    	    
   			config.instance = mpd;
   			config.monitor = mpdStandAloneMonitor;
    		
    		logger.debug("Connected to player '{}' with config {}", playerId, config);
    	}
    	
    }
	catch(MPDConnectionException ce) {
        logger.error("Error connecting to player '" + playerId + "' with config {}", config, ce);
    }
	catch (UnknownHostException uhe) {
    	logger.error("Wrong connection details for player {}", playerId, uhe);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:58,代码来源:MpdBinding.java

示例5: connect

import org.bff.javampd.monitor.MPDStandAloneMonitor; //导入依赖的package包/类
/**
 * Connects the player <code>playerId</code> to the given <code>host</code>
 * and <code>port</code> and registers this binding as MPD-Event listener.
 *
 * @param playerId
 * @param host
 * @param port
 */
private void connect(final String playerId) {
    MpdPlayerConfig config = null;
    try {

        config = playerConfigCache.get(playerId);
        if (config != null && config.instance == null) {

            MPD mpd = new MPD(config.host, config.port, config.password, CONNECTION_TIMEOUT);

            MPDStandAloneMonitor mpdStandAloneMonitor = new MPDStandAloneMonitor(mpd, 500);
            mpdStandAloneMonitor.addVolumeChangeListener(this);
            mpdStandAloneMonitor.addPlayerChangeListener(this);
            mpdStandAloneMonitor.addTrackPositionChangeListener(this);

            final MpdBinding self = this; // 'this' glue for the inner anon instance
            mpdStandAloneMonitor.addOutputChangeListener(new OutputChangeListener() {

                @Override
                public void outputChanged(OutputChangeEvent e) {
                    // We have to 'wrap' the OutputChangeEvent listener
                    // callback and add the playerId so we know which
                    // player generated the event. There's not enough
                    // info on just the OutputChangeEvent to derive
                    // the source player. This 'workaround' is necessary
                    // to support output control on multiple MPD players.
                    self.outputChanged(playerId, e);

                }

            });

            Thread monitorThread = new Thread(mpdStandAloneMonitor, "MPD Monitor (player:" + playerId + ")");
            monitorThread.start();

            config.instance = mpd;
            config.monitor = mpdStandAloneMonitor;

            logger.debug("Connected to player '{}' with config {}", playerId, config);
        }

    } catch (MPDConnectionException ce) {
        logger.error("Error connecting to player '{}' with config {}", playerId, config, ce);
    } catch (UnknownHostException uhe) {
        logger.error("Wrong connection details for player '{}'", playerId, uhe);
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:55,代码来源:MpdBinding.java

示例6: getMonitor

import org.bff.javampd.monitor.MPDStandAloneMonitor; //导入依赖的package包/类
/**
 * @return the MPD monitor instance
 */
public MPDStandAloneMonitor getMonitor()
{
	return monitor;
}
 
开发者ID:msteiger,项目名称:play-mpc,代码行数:8,代码来源:MpdMonitor.java


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