當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。