use of javax.microedition.media.MediaException in project CodenameOne by codenameone.
the class AdvancedMultimediaManager method setExposure.
public void setExposure(Controllable player) {
ExposureControl exposureControl = (ExposureControl) getControl(player, "javax.microedition.amms.control.camera.ExposureControl");
if (exposureControl != null) {
int[] supportedISOs = exposureControl.getSupportedISOs();
if (supportedISOs != null && supportedISOs.length > 0) {
int maxISO = Integer.MIN_VALUE;
for (int i = 0; i < supportedISOs.length; i++) {
if (supportedISOs[i] > maxISO) {
maxISO = supportedISOs[i];
}
}
try {
exposureControl.setISO(maxISO);
} catch (MediaException me) {
// continue
}
}
String[] supportedMeterings = exposureControl.getSupportedLightMeterings();
if (supportedMeterings != null) {
for (int i = 0; i < supportedMeterings.length; i++) {
if (DESIRED_METERING.equals(supportedMeterings[i])) {
exposureControl.setLightMetering(DESIRED_METERING);
break;
}
}
}
}
}
use of javax.microedition.media.MediaException in project CodenameOne by codenameone.
the class MMAPIPlayer method createPlayer.
public static MMAPIPlayer createPlayer(InputStream stream, String mimeType, Runnable onCompletion) throws IOException {
try {
Player p = Manager.createPlayer(stream, mimeType);
p.realize();
MMAPIPlayer m = new MMAPIPlayer(p);
m.bindPlayerCleanupOnComplete(p, stream, onCompletion);
return m;
} catch (MediaException ex) {
if ("audio/mpeg".equals(mimeType)) {
return createPlayer(stream, "audio/mp3", onCompletion);
}
ex.printStackTrace();
throw new IOException(ex.toString());
}
}
use of javax.microedition.media.MediaException in project CodenameOne by codenameone.
the class SnapshotThread method takeSnapshot.
private byte[] takeSnapshot() throws MediaException {
String bestEncoding = guessBestEncoding();
VideoControl videoControl = barCodeScanner.getVideoControl();
if (videoControl == null) {
throw new MediaException("Can't obtain video control");
}
byte[] snapshot = null;
try {
snapshot = videoControl.getSnapshot("".equals(bestEncoding) ? null : bestEncoding);
} catch (MediaException me) {
}
if (snapshot == null) {
// Fall back on JPEG; seems that some cameras default to PNG even
// when PNG isn't supported!
snapshot = videoControl.getSnapshot("encoding=jpeg");
if (snapshot == null) {
throw new MediaException("Can't obtain a snapshot");
}
}
return snapshot;
}
use of javax.microedition.media.MediaException in project CodenameOne by codenameone.
the class MMAPIPlayer method createPlayer.
public static MMAPIPlayer createPlayer(InputStream stream, String mimeType, Runnable onCompletion) throws IOException {
try {
Player p = Manager.createPlayer(stream, mimeType);
p.realize();
MMAPIPlayer m = new MMAPIPlayer(p);
m.bindPlayerCleanupOnComplete(p, stream, onCompletion);
return m;
} catch (MediaException ex) {
if ("audio/mpeg".equals(mimeType)) {
return createPlayer(stream, "audio/mp3", onCompletion);
}
ex.printStackTrace();
throw new IOException(ex.toString());
}
}
use of javax.microedition.media.MediaException in project CodenameOne by codenameone.
the class MMAPIPlayer method createPlayer.
/**
* @inheritDoc
*/
public static MMAPIPlayer createPlayer(String uri, Runnable onCompletion) throws IOException {
try {
Player p = Manager.createPlayer((String) uri);
p.realize();
MMAPIPlayer m = new MMAPIPlayer(p);
m.bindPlayerCleanupOnComplete(p, null, onCompletion);
return m;
} catch (MediaException ex) {
ex.printStackTrace();
throw new IOException(ex.toString());
}
}
Aggregations