本文整理汇总了Java中javax.microedition.media.Manager类的典型用法代码示例。如果您正苦于以下问题:Java Manager类的具体用法?Java Manager怎么用?Java Manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Manager类属于javax.microedition.media包,在下文中一共展示了Manager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPlayer
import javax.microedition.media.Manager; //导入依赖的package包/类
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());
}
}
示例2: createPlayer
import javax.microedition.media.Manager; //导入依赖的package包/类
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());
}
}
示例3: showCamera
import javax.microedition.media.Manager; //导入依赖的package包/类
private void showCamera() {
try {
mPlayer = Manager.createPlayer("capture://video");
mPlayer.realize();
mVideoControl = (VideoControl) mPlayer.getControl("VideoControl");
// Command mExitCommand = new Command("Exit", Command.EXIT, 0);
// Command mCameraCommand = new Command("Camera", Command.SCREEN, 0);
mBackCommand = new Command("Back", Command.BACK, 0);
mCaptureCommand = new Command("Capture", Command.SCREEN, 0);
Canvas canvas = new CameraCanvas(null, mVideoControl);
canvas.addCommand(mBackCommand);
canvas.addCommand(mCaptureCommand);
canvas.setCommandListener(this);
J2MEDisplay.setView(canvas);
mPlayer.start();
} catch (IOException ioe) {
handleException(ioe);
} catch (MediaException me) {
handleException(me);
}
}
示例4: open
import javax.microedition.media.Manager; //导入依赖的package包/类
public void open(String path){
try
{
player = Manager.createPlayer(path);
} catch (Exception e) {
e.printStackTrace();
Midlet.midlet.f.append("\nPlayer method open: " + e.getMessage());
}
}
示例5: playTone
import javax.microedition.media.Manager; //导入依赖的package包/类
public void playTone(int note, int duration, int volume) {
try {
Manager.playTone(note, duration, volume);
} catch (Exception e) {
e.printStackTrace();
Midlet.midlet.f.append("\nPlayer method playTone: " + e.getMessage());
}
}
示例6: MediaRecorder
import javax.microedition.media.Manager; //导入依赖的package包/类
public MediaRecorder(String path) throws IOException {
try {
String [] supportedContentType = Manager.getSupportedContentTypes("capture");
boolean amrSupported = false;
for (int i = 0; i < supportedContentType.length; i++) {
if(supportedContentType[i].equals("audio/amr")){
amrSupported = true;
}
}
if(amrSupported){
try {
//some j2me devices will report they supports amr, but they are actually
//don't so we will try to realize the player and if fails the
//fallback would be to create it with the default capture encoding
recorder = Manager.createPlayer("capture://audio?encoding=audio/amr");
recorder.realize();
} catch (Exception e) {
recorder = Manager.createPlayer("capture://audio");
recorder.realize();
}
}else{
recorder = Manager.createPlayer("capture://audio");
recorder.realize();
}
rc = (RecordControl) recorder.getControl("RecordControl");
out = FileSystemStorage.getInstance().openOutputStream(path);
rc.setRecordStream(out);
} catch (MediaException ex) {
ex.printStackTrace();
}
}
示例7: MediaRecorder
import javax.microedition.media.Manager; //导入依赖的package包/类
public MediaRecorder(String path, String mimeType) throws IOException {
try {
//recorder = Manager.createPlayer("capture://audio?encoding=audio/amr&bitrate=12200&voipMode=true");
recorder = Manager.createPlayer("capture://audio?encoding="+mimeType);
recorder.realize();
rc = (RecordControl) recorder.getControl("RecordControl");
out = FileSystemStorage.getInstance().openOutputStream(path);
rc.setRecordStream(out);
} catch (MediaException ex) {
ex.printStackTrace();
}
}
示例8: startScan
import javax.microedition.media.Manager; //导入依赖的package包/类
public void startScan() {
try {
System.gc();
player = Manager.createPlayer("capture://video");
player.realize();
multimediaManager.setZoom(player);
multimediaManager.setExposure(player);
multimediaManager.setFlash(player);
player.start();
videoControl = (VideoControl) player.getControl("VideoControl");
viewFinder = (Field) videoControl.initDisplayMode(
VideoControl.USE_GUI_PRIMITIVE,
"net.rim.device.api.ui.Field");
if (videoControl != null) {
viewFinderScreen = new ViewFinderScreen();
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
UiApplication.getUiApplication().pushScreen(
viewFinderScreen);
viewFinder.setFocus();
}
});
videoControl.setVisible(true);
videoControl.setDisplayFullScreen(true);
task = new BarcodeScanTask();
// create timer every 3 seconds, get a screenshot
timer = new Timer();
timer.schedule(task, 0, 3000); // once every 3 seconds
} else {
throw new MediaException("Video Control is not initialized");
}
} catch (Exception e) {
callback.scanError(-1, e.getMessage());
}
}
示例9: getPlayerLoose
import javax.microedition.media.Manager; //导入依赖的package包/类
public static Player getPlayerLoose(Reference reference) throws MediaException, IOException {
Player thePlayer;
try{
thePlayer = Manager.createPlayer(reference.getLocalURI());
final String uri = reference.getLocalURI();
thePlayer.addPlayerListener(new PlayerListener() {
public void playerUpdate(Player player, String event, Object eventData) {
logEvent(event, uri);
}
});
return thePlayer;
} catch(MediaException e) {
if(!FormManagerProperties.LOOSE_MEDIA_YES.equals(PropertyManager._().getSingularProperty(FormManagerProperties.LOOSE_MEDIA))) {
throw e;
}
Reference[] refs = reference.probeAlternativeReferences();
for(Reference ref : refs) {
if(ref.doesBinaryExist()) {
try{
//TODO: Make sure you create a player of the right type somehow (video/audio), don't want
//to accidentally send back an audio player of a video file
thePlayer = Manager.createPlayer(ref.getLocalURI());
return thePlayer;
}catch(MediaException oe) {
//also bad file, keep trying
}
}
}
throw e;
}
}
示例10: addCameraViewer
import javax.microedition.media.Manager; //导入依赖的package包/类
private void addCameraViewer() throws MediaException, IOException {
String refForCamera = "";
//#if polish.identifier.motorola/v3xx
refForCamera = "capture://camera";
//#elif polish.group.series60e3
refForCamera = "capture://devcam0";
//#else
refForCamera = "capture://video";
//#endif
String[] contentTypes = Manager.getSupportedContentTypes("capture");
if (contentTypes == null || contentTypes.length == 0) {
throw new MediaException("capture not supported");
}
for (int i = 0; i < contentTypes.length; i++) {
String contentType = contentTypes[i];
if ("image".equals(contentType)) { // this is the case on Series 40,
// for example
refForCamera = "capture://image";
}
}
System.out.println("Starting player");
player = Manager.createPlayer(refForCamera);
player.realize();
videoControl = (VideoControl) player.getControl("VideoControl");
videoItem = (javax.microedition.lcdui.Item) videoControl
.initDisplayMode(GUIControl.USE_GUI_PRIMITIVE, null);
showVideoScreen();
}
示例11: startPlayback
import javax.microedition.media.Manager; //导入依赖的package包/类
public void startPlayback() throws AudioException
{
try
{
try
{
audioDataStream = fileService.getFileOutputStream(recordFileName);
recordedInputStream = fileService.getFileDataStream(recordFileName);
}
catch(FileException fe)
{
audioDataStream = null;
recordedInputStream = null;
System.err.println("An error occurred while obtaining the file data stream.");
fe.printStackTrace();
}
if(audioDataStream == null || recordingDeleted)
{
throw new AudioException("No audio data recorded!");
}
playP = Manager.createPlayer(recordedInputStream, "audio/x-wav");
playP.prefetch();
playP.start();
serviceState = AudioCaptureService.PLAYBACK_STARTED;
}
catch(MediaException me)
{
throw new AudioException(me.getMessage());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
}
示例12: isMediaSupported
import javax.microedition.media.Manager; //导入依赖的package包/类
/**
* Returns boolean indication is media mimetype supported by the Device.
*
* @param mimeType
* String as media mime-type
* @return boolean is supported
*/
public boolean isMediaSupported(String mimeType) {
String[] types = Manager.getSupportedContentTypes(null);
for (int i = 0; i < types.length; i++) {
if (mimeType.toLowerCase().equals(types[i].toLowerCase())) {
return true;
}
}
return false;
}
示例13: init
import javax.microedition.media.Manager; //导入依赖的package包/类
private void init() {
String apiVersion = System.getProperty("microedition.media.version");
append("MM API version:" + apiVersion + "\n");
append("Mixing supported: " + System.getProperty("supports.mixing") + "\n");
append("Audio capture supported: " + System.getProperty("supports.audio.capture") + "\n");
append("Video capture supported: " + System.getProperty("supports.video.capture") + "\n");
append("Recording supported: " + System.getProperty("supports.recording") + "\n");
append("Supported audio encodings: " + System.getProperty("audio.encodings") + "\n");
append("Supported video encodings: " + System.getProperty("video.encodings") + "\n");
append("Supported video snaphot encodings: " + System.getProperty("video.snapshot.encodings") + "\n");
append("\n");
String streamable = System.getProperty("streamable.contents");
if (streamable == null) {
append("Streaming: not supported.\n");
} else {
append("Streamable contents: " + streamable);
String[] rtp = Manager.getSupportedContentTypes("rtp");
if (rtp != null && rtp.length > 0) {
append("RTP protocol supported.");
}
String rtsp[] = Manager.getSupportedContentTypes("rtsp");
if (rtsp != null && rtsp.length > 0) {
append("RTSP protocol supported.");
}
}
String[] contentTypes = Manager.getSupportedContentTypes(null);
if (contentTypes != null) {
append("\n\nAll supported content types:\n");
for (int i = 0; i < contentTypes.length; i++) {
append(contentTypes[i] + "\n");
}
}
}
示例14: restartPlayer
import javax.microedition.media.Manager; //导入依赖的package包/类
public synchronized void restartPlayer() {
try {
fireStatusEvent("Wait...");
IN.nextChunk();
// Free old player
if (player != null) {
for (int n = 0; n < listeners.size(); n++) {
this.player.removePlayerListener((PlayerListener) listeners.elementAt(n));
}
this.player.close();
this.player = null;
}
fireStatusEvent("Create Player...");
this.player = Manager.createPlayer(IN, IN.getContentType());
this.player.realize();
// Make sure radio is audible; this causes an VOLUME_CHANGED event
VolumeControl vcon = (VolumeControl) this.player.getControl("VolumeControl");
vcon.setMute(false);
vcon.setLevel(50);
for (int n = 0; n < listeners.size(); n++) {
this.player.addPlayerListener((PlayerListener) listeners.elementAt(n));
}
fireStatusEvent("Starting...");
this.player.start();
} catch (Exception ex) {
fireExecptionOccurredEvent(ex);
}
}
示例15: say
import javax.microedition.media.Manager; //导入依赖的package包/类
/**
* Diz o valor da nota
*/
void say(int value){
String valueSoundFile = null;
switch (value){
case 1:
valueSoundFile = "01.wav";
break;
case 2:
valueSoundFile = "02.wav";
break;
case 5:
valueSoundFile = "05.wav";
break;
case 10:
valueSoundFile = "10.wav";
break;
case 20:
valueSoundFile = "20.wav";
break;
case 50:
valueSoundFile = "50.wav";
break;
case 100:
valueSoundFile = "100.wav";
break;
default:
valueSoundFile = "unknown.wav";
break;
}
try {
InputStream is = getClass().getResourceAsStream(valueSoundFile);
Player audioPlayer = Manager.createPlayer(is, "audio/X-wav");
audioPlayer.start();
} catch (IOException ioe) {
} catch (MediaException me) { }
}