FileDocCategorySizeDatePackage
JavaSoundAuto.javaAPI DocJMF 2.1.1e2100Mon May 12 12:20:34 BST 2003None

JavaSoundAuto

public class JavaSoundAuto extends Object

Fields Summary
private static final String
detectClass
CaptureDeviceInfo[]
devices
Constructors Summary
public JavaSoundAuto()

	boolean supported = false;
	// instance JavaSoundDetector to check is javasound's capture is availabe
	try {
	    Class cls = Class.forName(detectClass);
	    JavaSoundDetector detect = (JavaSoundDetector)cls.newInstance();
	    supported = detect.isSupported();
	} catch (Throwable t) {
	    supported = false;
	    // t.printStackTrace();
	}
	
	System.out.println("JavaSound Capture Supported = " + supported);

	if (supported) {
	    // It's there, start to register JavaSound with CaptureDeviceManager
	    Vector devices = (Vector) CaptureDeviceManager.getDeviceList(null).clone();
	    
	    // remove the old javasound capturers
	    String name;
	    Enumeration enum = devices.elements();
	    while (enum.hasMoreElements()) {
		CaptureDeviceInfo cdi = (CaptureDeviceInfo) enum.nextElement();	
		name = cdi.getName();
		if (name.startsWith("JavaSound"))
		    CaptureDeviceManager.removeDevice(cdi);
	    }
	    
	    // collect javasound capture device info from JavaSoundSourceStream
	    // and register them with CaptureDeviceManager
	    CaptureDeviceInfo[] cdi =  com.sun.media.protocol.javasound.JavaSoundSourceStream.listCaptureDeviceInfo();
	    if ( cdi != null ){
		for (int i = 0; i < cdi.length; i++)
		    CaptureDeviceManager.addDevice(cdi[i]);
		try {
		    CaptureDeviceManager.commit();
		    System.out.println("JavaSoundAuto: Committed ok");
		} catch (java.io.IOException ioe) {
		    System.err.println("JavaSoundAuto: error committing cdm");
		}
	    }
		
	}
    
Methods Summary
public static voidmain(java.lang.String[] args)


         
       new JavaSoundAuto();
       System.exit(0);