Methods Summary |
---|
public static Player | createPlayer(java.lang.String locator)
if (locator == null) {
throw new IllegalArgumentException();
}
String locStr = locator.toLowerCase();
String validLoc;
if (locStr.equals(validLoc = TONE_DEVICE_LOCATOR)) {
ABBBasicPlayer p;
// separate device & encodings
int encInd = locator.indexOf('?");
String encStr = null;
if (encInd > 0) {
encStr = locator.substring(encInd + 1);
locStr = locStr.substring(0, encInd);
/*
* TBD: check case when '?' is the last Locator symbol:
*Will encStr be == "", or it will be == null ?
*/
} else {
/*
* detect invalid locator case:
* if no '?' found then locStr & validLoc shall be
* equivalent strings, but since they have already passed
* char-to-char comparison, we to check lengths only...
*/
if (locStr.length() != validLoc.length())
throw new MediaException("Malformed locator");
encStr = "";
}
String className = config.getHandler(locStr);
try {
// Try and instance the player ....
Class protoClass = Class.forName(className);
p = (ABBBasicPlayer) protoClass.newInstance();
// Pass encStr to created Player as argument
if (!p.initFromURL(encStr)) {
throw new MediaException("Invalid locator media encodings");
};
//System.out.println("DEBUG: Manager.createPlayer(" + locator + ") returned#1 " + p);
return p;
} catch (Exception e) {
throw new MediaException(PL_ERR + locator +
REDIRECTED_MSG + e.getMessage());
}
} else {
// not in the list of predefined locators,
// find handler by extension
String theProtocol = null;
int idx = locStr.indexOf(':");
if (idx != -1) {
theProtocol = locStr.substring(0, idx);
} else {
throw new MediaException("Malformed locator");
}
String[] supported = getSupportedProtocols(config.ext2Mime(locStr));
boolean found = false;
for (int i = 0; i < supported.length; i++) {
if (theProtocol.equals(supported[i])) {
found = true;
break;
}
}
if (!found) {
throw new MediaException(PL_ERR + locator);
}
Player pp = null;
throw new MediaException("Not supported");
//System.out.println("DEBUG: Manager.createPlayer(" + locator + ") returned#2 " + pp);
// return pp;
}
|
public static Player | createPlayer(java.io.InputStream stream, java.lang.String type)
if (stream == null) {
throw new IllegalArgumentException();
}
if (type == null) {
throw new MediaException(PL_ERR + "NULL content-type");
}
throw new MediaException("Not supported");
|
public static java.lang.String[] | getSupportedContentTypes(java.lang.String protocol)
return config.getSupportedContentTypes(protocol);
|
public static java.lang.String[] | getSupportedProtocols(java.lang.String content_type)
return config.getSupportedProtocols(content_type);
|
public static void | playTone(int note, int duration, int volume)
if (note < 0 || note > 127 || duration <= 0) {
throw new IllegalArgumentException("bad param");
}
if (duration == 0 || volume == 0) {
return;
}
synchronized(createLock) {
if (tonePlayer == null) {
tonePlayer = config.getTonePlayer();
}
}
if (tonePlayer != null) {
tonePlayer.playTone(note, duration, volume);
} else {
throw new MediaException("no tone player");
}
|