Sound recording can be done by using RecordControl. Series 40 platform supports sound recording from 3rd Edition, Feature Pack 1 onwards. You can check the support by using the following system properties:
supports.audio.capture - for audio recording
These properties return true if recording is supported.
When creating a Player for audio capture, or specific capture, the locator URL must be used as a parameter to the createPlayer method of the Manager class. The following code line creates a Player instance for audio capture:
Player p = Manager.createPlayer("capture://audio");
Camera snapshot for pictures or audio recording use the following locators:
Photo capture locator:
capture://image
Audio capture locator:
capture://audio
You can also define the exact recorded media type to the locator URL. The supported parameters vary between platforms and devices. Note that SDKs might not support capture features at all, so testing should be done with the actual mobile devices. For further details about recording, check the (JSR-135) Mobile Media API.
From Nokia Asha software platform 1.4 onwards, JSR-135 (Mobile Media API) supports audio progressive recording (or audio stream sending while recording) using RecordControl::setRecordStream(OutputStream stream). Audio progressive recording means that recording data is continuously flushed during recording.
Audio progressive recording provides a more real-time voice messaging experience by starting the transfer even before the user has finished the recording. The aim is to improve usability and performance of voice messages. Intervals of data availability, buffer size and so on should be configurable so that the MIDlet can tweak it as necessary. The following example code demonstrates how to use Audio progressive recording:
FileConnection fc =(FileConnection) Connector.open("file:///MemoryCard/recording.amr", Connector.READ_WRITE); OutputStream outputStream = fc.openOutputStream(); Player capturePlayer = Manager.createPlayer("capture://audio"); RecordControl recordControl = (RecordControl) capturePlayer.getControl("RecordControl"); recordControl.setRecordStream(outputStream); capturePlayer.start(); recordControl.startRecord(); // now, recording data is continuously streamed into OutputStream immediately (here is file "recording.amr"). // commit recording data recordControl.commit(); // gurantees that all recording data is streamed into OutputStream. //or discard recording data recordControl.reset(); // streaming output stops immediately but MIDlet should discard received data by itself.