熟练使用J2ME在实际开发中的可选包MMAPI |
| 作者:未知 来源:J2ME开发网 发布时间:2005-7-29 9:21:43 |
|
和录音功能的实现 try { // Create a DataSource that captures live audio. Player p = Manager.createPlayer ("capture://audio"); p.realize(); // Get the RecordControl, set the record location, and // start the Player and record for 5 seconds. RecordControl rc = (RecordControl)p.getControl ("RecordControl"); rc.setRecordLocation ("file:/tmp/audio.wav"); rc.startRecord(); p.start(); Thread.currentThread() .sleep(5000); p.stop(); rc.stopRecord(); rc.commit(); } catch (IOException ioe) { } catch (MediaException me) { } catch (InterruptedException e) { } 实现摄像功能 Player p; VideoControl vc; // initialize camera try { p = Manager.createPlayer ("capture://video"); p.realize(); // Grab the video control and set it to the current display. vc = (VideoControl)p.getControl ("VideoControl"); if (vc != null) { Form form = new Form("video"); form.append((Item)vc.initDisplayMode (vc.USE_GUI_PRIMITIVE, null)); Display.getDisplay(midlet).setCurrent(form); } p.start(); } catch (IOException ioe) { } catch (MediaException me) { } // now take a picture try { byte[] pngImage = vc.getSnapshot(null); // do something with the image ... } catch (MediaException me) { } 在后面的文章中我们将通过完整的实例演示如何使用MMAPI开发应用程序。 |
| [] [返回上一页] [打 印] |
|
文章评论 |
