×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    1

    Unable to record voice in N70

    Hi everyone,
    I am developing a voice chat application for which i need to record the voice in amr format for 2-5 sec and send it to the server. But the thing is i'm unable to the record the voice itself in N70 where as the code works fine in emulator Java(TM) ME Platform SDK 3.0. My code to record the voice -

    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.util.*;
    import javax.microedition.io.file.*;



    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("Recording your voice ...\n\n");


    p = Manager.createPlayer("capture://audio");//?encoding=amr");

    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();


    }
    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());
    }

    }


    }

    }

    Please tell me the changes to be made in this code to make this work in N70 phones.
    Thanks in advance.

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: Unable to record voice in N70

    Welcome to the Forum Nokia Discussion Boards...

    When you are saying that you are not able to record the audio on the Nokia N70, what exactly you are pointing to?
    Are you getting some error/exception/error dialogs?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

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. record voice and send to the server in real time
    By mekal2002 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2010-11-22, 08:19
  3. Unable to Install the jar file in N70
    By ayan_sen in forum Mobile Java General
    Replies: 9
    Last Post: 2010-04-14, 17:16
  4. Nokia N70 - Unable to create folder/file in c:\
    By chrishagmann in forum Symbian
    Replies: 1
    Last Post: 2006-04-27, 04:10
  5. Is it possible to record voice calls in 8310?
    By zanwar in forum General Development Questions
    Replies: 0
    Last Post: 2005-04-21, 07:40

Posting Permissions

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