⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mediaserverfactory.java

📁 国外的j2me播放器软件
💻 JAVA
字号:
package no.auc.one.portableplayer.communication.mediaserver;

import java.util.Vector;

import org.apache.log4j.*;
import org.xml.sax.SAXException;

import no.auc.one.portableplayer.communication.*;

public final class MediaServerFactory extends UPnPDeviceFactory {
	private static Logger LOG = Logger.getLogger("MS");
	
	/**
	 * Find all media servers available.
	 */
	public Vector findMediaServers() {
		return findMediaServers("urn:schemas-upnp-org:device:MediaServer:1");
	}
    
    public Vector findMediaServers(String searchString) {
		return super.findUPnPDevice(
            searchString,
			new MediaServerDeviceDescriptionHandler());
    }
    
    public MediaServer getMediaServer(String locationUrl) {
		MediaServer ms = null;
    			
        ms = (MediaServer)super.getUPnPDevice(
                locationUrl, 
                new MediaServerDeviceDescriptionHandler(locationUrl));

        if (ms != null) {
            LOG.debug(
                "MediaServer found " + 
                " Name:" + ms.getFriendlyName() + 
                " URLBase:"  + ms.getURLBase() + 
                " CDS:" + ms.getContentDirectoryService().toString());
        }
        
        return ms;
    }
    	
    private class MediaServerDeviceDescriptionHandler extends UPnPDeviceDescriptionHandler {
    	private MediaServer ms;
        
    	public MediaServerDeviceDescriptionHandler() {
            super();
        }
		
    	public MediaServerDeviceDescriptionHandler(String url) {
            super(url);
        }
        
        public void endDocument() throws SAXException {
            super.endDocument();
            
    		if (services == null) {
    			return;
    		}
			
			ms = new MediaServer(dev);
			dev = (UPnPDevice)ms;

        	for (int i=0; i < services.size(); i++){
        		UPnPService currentService = (UPnPService)services.elementAt(i);
        		
        		if (currentService == null) {
        			continue;
        		}
                
        		if (currentService.getServiceType().equals("urn:schemas-upnp-org:service:ContentDirectory:1")){
                    ms.setContentDirectoryService(
						new ContentDirectoryService(currentService));
                    break;  // FYI: If more services are needed to be 
                            //      initialized in the future then this break
                            //      statement must be removed!
        		}
        	}
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -