javax.microedition.media.Manager Java Examples
The following examples show how to use
javax.microedition.media.Manager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MMAPIPlayer.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
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()); } }
Example #2
Source File: MMAPIPlayer.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
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()); } }
Example #3
Source File: MediaRecorder.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
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(); } }
Example #4
Source File: SupportForm.java From pluotsorbet with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example #5
Source File: PlayerPool.java From pluotsorbet with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #6
Source File: CodeScannerImpl.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
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()); } }
Example #7
Source File: MediaRecorder.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
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(); } }
Example #8
Source File: MMAPIPlayer.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * @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()); } }
Example #9
Source File: Sound.java From J2ME-Loader with Apache License 2.0 | 5 votes |
public void init(int freq, long duration) { try { player = Manager.createPlayer(Manager.TONE_DEVICE_LOCATOR); state = SOUND_STOPPED; } catch (IOException e) { e.printStackTrace(); } }
Example #10
Source File: MMAPIPlayer.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * @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()); } }
Example #11
Source File: AudioClip.java From J2ME-Loader with Apache License 2.0 | 5 votes |
public AudioClip(int type, byte[] audioData, int audioOffset, int audioLength) { try { player = Manager.createPlayer(new ByteArrayInputStream(audioData), "audio/mmf"); } catch (IOException e) { e.printStackTrace(); } }
Example #12
Source File: AudioClip.java From J2ME-Loader with Apache License 2.0 | 5 votes |
public AudioClip(int type, java.lang.String filename) throws IOException { try { InputStream stream = ContextHolder.getResourceAsStream(null, filename); player = Manager.createPlayer(stream, "audio/midi"); } catch (IOException e) { e.printStackTrace(); } }
Example #13
Source File: Clip.java From J2ME-Loader with Apache License 2.0 | 5 votes |
protected Player getPlayer() { Player player = null; try { if (data != null) { player = Manager.createPlayer(new ByteArrayInputStream(data), contentType); } else { player = Manager.createPlayer(str); } } catch (IOException e) { e.printStackTrace(); } return player; }
Example #14
Source File: Sound.java From J2ME-Loader with Apache License 2.0 | 5 votes |
public void init(byte[] data, int type) { try { player = Manager.createPlayer(new ByteArrayInputStream(data), "audio/midi"); state = SOUND_STOPPED; } catch (IOException e) { e.printStackTrace(); } }
Example #15
Source File: GlobalManager.java From J2ME-Loader with Apache License 2.0 | 4 votes |
public static String[] getSupportedSoundSource3DPlayerTypes() { return Manager.getSupportedContentTypes(null); }
Example #16
Source File: PlayerPool.java From pluotsorbet with GNU General Public License v2.0 | 3 votes |
/** * Creates and initializes the Player * * @param sequence - * tone sequence data in byte array * @return realized tone sequence Player * @throws MediaException * thrown by the system while creating the player * @throws IOException * thrown by the system while creating the player */ private Player createTonePlayer(byte[] sequence) throws MediaException, IOException { Player player = Manager.createPlayer(Manager.TONE_DEVICE_LOCATOR); player.addPlayerListener(this); player.realize(); ToneControl tc = (ToneControl) (player.getControl("ToneControl")); tc.setSequence(sequence); return player; }
Example #17
Source File: PlayerPool.java From pluotsorbet with GNU General Public License v2.0 | 3 votes |
/** * Creates and initializes the Player. * * @param media - * Media datatype that represents the data * @return realized Player * @throws MediaException * occured while creating the player * @throws IOException * occured while creating the player */ private Player createPlayer(Media media) throws MediaException, IOException { InputStream is = media.getInputStream(); String mediaType = media.getType(); Player player = Manager.createPlayer(is, mediaType); player.addPlayerListener(this); player.realize(); player.prefetch(); return player; }