Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2007

    Recording midlet problem

    Im making a midlet that records audio and saves it to phone's file system. I get the application to run in emulator but when in phone i immediately get error Cannot create a DataSource for: null. Here is the code i'm trying to get to work: (i tried to change the file:///test.wav to file:///e:/test.wav but it didn't help. Also i got a version of this code without the save function but it doesn't work in phone either, it just says error.

    So here's the code:
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.*;
    import javax.microedition.media.control.RecordControl;

    public class SaveCapturedAudioMIDlet extends MIDlet
    implements CommandListener {

    // the display items
    private Display display = null;
    private Alert alert = null;
    private Command exitCommand = null;

    // players and controls
    private Player capturePlayer = null;
    private Player playbackPlayer = null;
    private RecordControl rControl = null;

    private boolean error = false;

    public SaveCapturedAudioMIDlet() {

    // create the display
    display = Display.getDisplay(this);
    alert = new Alert("Message");
    alert.setString("Capturing for 10 seconds. Say something intelligent!");
    exitCommand = new Command("Exit", Command.EXIT, 1);

    try {

    // create the capture player
    capturePlayer = Manager.createPlayer("capture://audio");

    if (capturePlayer != null) {

    // if created, realize it

    // and grab the RecordControl
    rControl = (RecordControl)capturePlayer.getControl(

    // set the alert as the current item

    // if it is null throw exception
    if(rControl == null) throw new Exception("No RecordControl available");

    // and set the destination for this captured data

    } else {
    throw new Exception("Capture Audio Player is not available");

    } catch(Exception e) {

    public void startApp() {

    if(error) return;

    try {

    // first start the corresponding recording player

    // and then start the RecordControl

    // now record for 10 seconds

    // stop recording after time is up

    // commit the recording

    // stop the Player instance

    // and close it to release the microphone

    // finally, create a Player instance to playback
    // check your device documentation to find out the root.
    // The following will work on devices that have the root
    // specified as shown
    playbackPlayer = Manager.createPlayer("file:///test.wav");

    // and start it

    } catch(Exception e) {

    public void pauseApp() {

    public void destroyApp(boolean unconditional) {
    if(capturePlayer != null) capturePlayer.close();
    if(playbackPlayer != null) playbackPlayer.close();

    public void commandAction(Command cmd, Displayable disp) {
    if(cmd == exitCommand) {

    // general purpose error method, displays on screen as well to output
    private void error(Exception e) {
    error = true;

  2. #2
    Regular Contributor
    Join Date
    Aug 2006

    Re: Recording midlet problem

    Take a look at this doc, the MIDP Mobile Media API Developers Guide: http://www.forum.nokia.com/info/sw.n..._1_en.pdf.html

    First of all, check if your phone supports audio capturing, by asking the "supports.audio.capture" property from the system.

    Then, take a look at this document, the MIDP Mobile Media API Support In Nokia Devices, in order to check if your phone is supporting *.wav capturing: http://www.forum.nokia.com/info/sw.n..._0_en.pdf.html

    As far as I remember, the file URL on a real Nokia phone should be "file:///c:/test.wav" (if file is on the phone's internal memory) or "file:///e:/test.wav" (if file is on the memory card).

    And finally, take a look at this media capturing article, based on a good book: http://www.awprofessional.com/articl...&seqNum=4&rl=1
    Especially on the Capture Audio chapter.
    Last edited by axs; 2007-05-21 at 07:14.

  3. #3
    Registered User
    Join Date
    Oct 2006

    Re: Recording midlet problem

    you also need to check whether the phone supports PDA API for access to the file system in the phone. This can be done by

    boolean FILECHECK = "1.0".equals(System.getProperty("microedition.io.file.FileConnection.version");
    Sreekanth Bellur,
    Symbian C++ Developer,
    Ravensoft Ltd.,
    United Kingdom

Similar Threads

  1. MIDlet upload photo problem
    By Kmcgivern in forum Mobile Java General
    Replies: 3
    Last Post: 2008-09-09, 09:21
  2. 7210: Problem when midlet connect to servlet
    By wanning in forum Mobile Java General
    Replies: 10
    Last Post: 2008-05-14, 16:44
  3. Nokia 6300: midlet installation problem
    By rabbini in forum Mobile Java General
    Replies: 9
    Last Post: 2007-10-11, 10:06
  4. Problem with recording
    By sheenanaseer in forum Symbian
    Replies: 2
    Last Post: 2006-07-06, 13:03
  5. Problem downloading midlet to Nokia6600
    By sgreid101 in forum Mobile Java General
    Replies: 3
    Last Post: 2004-08-12, 11:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts