private void showCamera() { try { releaseResources(); player = Manager.createPlayer("capture://video"); player.addPlayerListener(this); player.realize(); videoControl = (VideoControl) player.getControl("VideoControl"); aVideoCanvas = new VideoCanvas(); aVideoCanvas.initControls(videoControl, player); aVideoCanvas.addCommand(CMD_RECORD); aVideoCanvas.addCommand(CMD_EXIT); aVideoCanvas.setCommandListener(this); parentMidlet.getDisplay().setCurrent(aVideoCanvas); player.start(); contentType = player.getContentType(); } catch (Exception e) { e.printStackTrace(); } }
/** @param args */ public static void main(String[] args) { String url = "rtp://192.168.1.1:22224/audio/16"; MediaLocator mrl = new MediaLocator(url); // Create a player for this rtp session Player player = null; try { player = Manager.createPlayer(mrl); } catch (NoPlayerException e) { e.printStackTrace(); System.exit(-1); } catch (MalformedURLException e) { e.printStackTrace(); System.exit(-1); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } if (player != null) { System.out.println("Player created."); player.realize(); // wait for realizing while (player.getState() != Controller.Realized) { try { Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } } System.out.println("Starting player"); player.start(); } else { System.err.println("Player doesn't created."); System.exit(-1); } System.out.println("Exiting."); }
/** * Creates a new instance of Recorder * * @param buffer the shared Buffer. * @param controller the controlling TunerMIDlet instance. */ public Recorder(Buffer buffer, TunerMIDlet controller) { this.buffer = buffer; this.controller = controller; // Buffer filling time (s) is FFT length / sample rate (* 1000ms). recordingTime = 1000 * controller.getSampleLength() / TunerMIDlet.RATE; if (capturePlayer == null) { try { capturePlayer = Manager.createPlayer("capture://audio?encoding=pcm&rate=" + TunerMIDlet.RATE); capturePlayer.realize(); recordControl = (RecordControl) capturePlayer.getControl("RecordControl"); // Create the internal buffer for the recording bos = new ByteArrayOutputStream(controller.getSampleLength()); } catch (Exception e) { // No point continuing without a capturePlayer or recordControl so show fatal error. controller.showError(e.getMessage(), new FatalForm(controller)); } } }