×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    8

    voice recording in j2me

    Hi,all
    i have problem descirbed below plz help me as soon as possible.
    i am recording voice and then playback in phone but only plays 5 seconds recording voice i want to store more minutes recording then how to manage it. how to store in memory? is it possible or not?
    plz reply me

  2. #2
    Registered User
    Join Date
    Mar 2007
    Posts
    46

    Re: voice recording in j2me

    Hi,amitkalyani
    It possible to implements what you want,you can use RecordControl in JSR135 to control recording voice

    Best regards

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    11

    Re: voice recording in j2me

    hi
    i'm trying to save audio as well but i have an exception that i couldn't solve
    can you please give me some steps how you saved that audio
    i'll be grateful
    thanks

  4. #4
    Regular Contributor
    Join Date
    Jan 2007
    Location
    Bangalore, India
    Posts
    100

    Re: voice recording in j2me

    Quote Originally Posted by Mr.Developer
    hi
    i'm trying to save audio as well but i have an exception that i couldn't solve
    can you please give me some steps how you saved that audio
    i'll be grateful
    thanks
    I trhink this link might be useful for you as it deals with saving the recorded audio.
    http://discussion.forum.nokia.com/fo...d.php?t=100712
    Any more clarifications can ask. If you could tell the Exception thats occuring may be we can try to solve it as well
    with regards,
    with regards,
    Khalandar Pasha N
    (khalandar_p@yahoo.co.in)

  5. #5
    Registered User
    Join Date
    Mar 2007
    Posts
    8

    Re: voice recording in j2me

    thanks for replying.
    i put my code below plz solve it
    i am trying lots but i am not success to develop it.
    thanks in advanced
    i just store 5 seconds but i want to store more minutes of data in file.

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.control.*;
    import javax.microedition.media.*;
    import javax.microedition.io.*;
    import java.io.*;
    import java.lang.*;
    import java.util.*;



    public class RecordForm extends MIDlet implements CommandListener
    {
    private Display display;

    private Form form;

    private Command record;
    private Command play;
    private Command exit;

    private Player p;

    private byte[] recordedSoundArray = null;

    public RecordForm()
    {
    display = Display.getDisplay(this);

    record = new Command("Record", Command.SCREEN, 1);
    play = new Command("Play", Command.SCREEN, 2);
    exit=new Command("exit",Command.SCREEN,3);

    form = new Form("Recording Example");
    form.addCommand(record);
    form.addCommand(play);
    form.addCommand(exit);
    form.setCommandListener(this);
    }

    public void startApp()
    {
    display.setCurrent(form);
    }

    public void pauseApp()
    {
    }

    public void destroyApp(boolean unconditional)
    {
    }

    public void commandAction(Command comm, Displayable disp)
    {
    if(comm==record)
    {
    Thread t = new Thread()
    {
    public void run()
    {
    try
    {
    form.append("record voice ...\n\n");

    String[] types= Manager.getSupportedContentTypes("capture");
    for( int i= 0; i < types.length; i++ )
    {
    form.append(types[i]);
    }

    // p = Manager.createPlayer("capture://audio?encoding=pcm");
    //p = Manager.createPlayer("capture://audio?rate=8000&bits=16");
    p = Manager.createPlayer("capture://audio");//?encoding=amr");
    // p = Manager.createPlayer("capture://audio?rate=8000&bits=8&Channels=1");
    // p=Manager.createPlayer("capture://devmic0?encoding=pcm");
    //p=Manager.createPlayer("rtp://192.168.2.2:8000/audio");
    p.realize();
    RecordControl rc = (RecordControl)p.getControl("RecordControl");

    ByteArrayOutputStream output = new ByteArrayOutputStream();
    rc.setRecordStream(output);
    rc.startRecord();
    p.start();
    form.append("recording...\n");
    form.removeCommand(play);
    Thread.currentThread().sleep(5000); // record for 5 seconds
    form.append("done!");
    form.addCommand(play);
    p.stop();
    rc.stopRecord();
    rc.commit();
    recordedSoundArray = output.toByteArray();
    p.close();
    getRoots();
    }
    catch (IOException ioe)
    {
    form.append("Error 1:"+ioe.toString());
    }
    catch (MediaException me)
    {
    form.append("Error 2:"+me.toString());
    }
    catch (InterruptedException ie)
    {
    form.append("Error 3:"+ie.toString());
    }
    }
    };t.start();

    }
    else if(comm == play)
    {
    Thread a = new Thread()
    {
    public void run()
    {
    try
    {
    form.deleteAll();
    form.append("playing...\n");
    form.append("recorded sound = " +String.valueOf(recordedSoundArray.length)+"\n\n");
    ByteArrayInputStream recordedInputStream = new ByteArrayInputStream(recordedSoundArray);
    Player p2 = Manager.createPlayer(recordedInputStream,"audio/x-wav");
    p2.prefetch();
    p2.start();

    }
    catch (IOException ioe)
    {

    form.append("Error 3:"+ioe.toString());
    }
    catch (MediaException me)
    {
    form.append("Error 4:"+me.toString());
    }
    }
    };a.start();
    }
    else if (comm==exit)
    {
    try
    {
    destroyApp(false);
    notifyDestroyed();
    }
    catch (Exception ioe)
    {
    form.append("Error 5:"+ioe.toString());
    }

    }


    }

    private void getRoots()
    {
    Enumeration drives = javax.microedition.io.file.FileSystemRegistry.listRoots();
    while(drives.hasMoreElements())
    {
    String root = (String) drives.nextElement();
    form.append(root);
    }
    }
    }

  6. #6
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: voice recording in j2me

    I have provided some sample code in the link that "khalandar" have pointed. Please let me know what exception are you getting and in which phone you are trying.

    Regards
    Gopal

    __________________
    MobiQuil.com
    An initiative by Developers for Developers.
    http://www.mobiquil.com - Alpha - Launched.

  7. #7
    Regular Contributor
    Join Date
    Jan 2007
    Location
    Bangalore, India
    Posts
    100

    Re: voice recording in j2me

    If Iam not wrong your problem is storing minutes of data instead of 5 seconds right..If yes, then the solution is simple you are stopping the player after 5 seconds i.e by using thread.sleep(5000) and then stopping the player instead of that increase the sleep period for the amount of time you want (say 1minute etc...)or what you can do is add one more command to the Form say a stopRECCommand and when this is pressed only then you stop the player as well as recording. I hope that solves your problem. Iam not in office else may be I would have sent you the changed program itself. I hope this solution works.
    with regards,
    with regards,
    Khalandar Pasha N
    (khalandar_p@yahoo.co.in)

  8. #8
    Registered User
    Join Date
    Mar 2007
    Posts
    8

    Re: voice recording in j2me

    thanks for replying.
    i am not got any exception code is running but it store only 5 seconds recording i want more than 5 seconds means 1 minutes to 1 hours if possible.
    reply me
    thanks

  9. #9
    Registered User
    Join Date
    Mar 2007
    Posts
    8

    Re: voice recording in j2me

    Quote Originally Posted by khalandar
    If Iam not wrong your problem is storing minutes of data instead of 5 seconds right..If yes, then the solution is simple you are stopping the player after 5 seconds i.e by using thread.sleep(5000) and then stopping the player instead of that increase the sleep period for the amount of time you want (say 1minute etc...)or what you can do is add one more command to the Form say a stopRECCommand and when this is pressed only then you stop the player as well as recording. I hope that solves your problem. Iam not in office else may be I would have sent you the changed program itself. I hope this solution works.
    with regards,

    thanks for reply
    i am increase the seconds but there is not any kind of changed becoz it stores only 5 seconds data.
    thanks for nice reply

  10. #10
    Regular Contributor
    Join Date
    Jan 2007
    Location
    Bangalore, India
    Posts
    100

    Re: voice recording in j2me

    Could you please tell me the Emulator/ Phone you are working on. So that i can try the code on the same and if possible help you.
    With regards,
    with regards,
    Khalandar Pasha N
    (khalandar_p@yahoo.co.in)

  11. #11
    Registered User
    Join Date
    Mar 2007
    Posts
    8

    Re: voice recording in j2me

    Quote Originally Posted by khalandar
    Could you please tell me the Emulator/ Phone you are working on. So that i can try the code on the same and if possible help you.
    With regards,
    thanks for reply
    i am testing on nokia 3230 and emulator is wireless toolkit 2.2
    is there use of rms or not for storing file?
    plz help

  12. #12
    Registered User
    Join Date
    Jan 2008
    Posts
    1

    Re: voice recording in j2me

    Hi,

    I am using the same type of code for Record and Playback, that works on Nokia7210 supernova but when i switch to Nokia N73 it did NOT play back the recorded data.

    The issues i have seen on N73:

    1) If i use Manager.createPlayer("capture://audio"), and try to play back as "audio/amr" then it plays a garbage data of very long duration though the actual recording was ~10 sec.

    2) if after using Manager.createPlayer("capture://audio"), GetContentType returns audio/wav, in this case if I playback this data with audio/x-wav, then it returns an error. (NOTE: There is no codec like audio/wav for playback.)

    3) If i use Manager.createPlayer("capture://audio?encoding=amr"), and try to play back as "audio/amr" then the player run for the exact recorded time but there was NO audio.

    Any suggestion, please help.

  13. #13
    Regular Contributor
    Join Date
    Jan 2007
    Location
    Bangalore, India
    Posts
    100

    Re: voice recording in j2me

    Hi Vikas,

    I'm extremely sorry as i'm no longer working in J2ME & its been 2+ years since I touched it so I'm not remembering anything that i had done. Will try & recall the way i has done & if I do remember then will reply back.

    Khalandar Pasha N
    with regards,
    Khalandar Pasha N
    (khalandar_p@yahoo.co.in)

  14. #14
    Registered User
    Join Date
    Dec 2009
    Posts
    1

    Wink Re: voice recording in j2me

    the above discussion is really nice and informative.i loved to join it......
    web page

Similar Threads

  1. use Java Native Interface to record voice in J2ME
    By walterzcm in forum Mobile Java General
    Replies: 3
    Last Post: 2012-12-07, 11:27
  2. Unlimited Audio Recording with J2ME on nokia 6630
    By basitj in forum Mobile Java Media (Graphics & Sounds)
    Replies: 11
    Last Post: 2010-12-29, 15:23
  3. Voice recording on 9500 / 9300
    By omarsc in forum General Development Questions
    Replies: 0
    Last Post: 2006-04-28, 10:10
  4. voice recording in MMS
    By walterzcm in forum General Messaging
    Replies: 1
    Last Post: 2002-11-19, 05:17

Posting Permissions

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