Audio J2ME Code

Hello,
hi i am working on audio recorder in j2me 2.0 Ktoolbar emulator but i have been stucked up , please help me out in solving the problem,while running it wil say that it is not possible to create a player for audio/basic.i have given my code down please try to check and i am desperately need of it.
public void commandAction(Command comm, Displayable disp) {
if(comm==recordCommand) {
try {
// create the Player object using amr encoding
//p = Manager.createPlayer("capture://audio?encoding=amr");
System.out.println("hi");
p = Manager.createPlayer("capture://audio?rate=8000&bits=8&Channels=1");
//System.out.println("hi");
// p=Manager.createPlayer("capture://devmic0?encoding=pcm");
//p=Manager.createPlayer("rtp://192.168.2.2:8000/audio");
p.realize();
// get the RecordControl over this Player
RecordControl rc = (RecordControl)p.getControl("RecordControl");
// create an OutputStream which the RecordControl will use
// to write write the recorded data.
ByteArrayOutputStream output = new ByteArrayOutputStream();
rc.setRecordStream(output);
// start the recording
rc.startRecord();
p.start();
messageItem.setText("recording...");
Thread.currentThread().sleep(5000); // record for 5 seconds
messageItem.setText("done!");
rc.commit();
// save the recordedData in a byte array
recordedSoundArray = output.toByteArray();
// close the player
p.close();
} catch (IOException ioe) {
errorItem.setLabel("Error");
errorItem.setText(ioe.toString());
} catch (MediaException me) {
errorItem.setLabel("Error");
errorItem.setText(me.toString());
} catch (InterruptedException ie) {
errorItem.setLabel("Error");
errorItem.setText(ie.toString());
} else if(comm == playCommand) {
try {
ByteArrayInputStream recordedInputStream = new ByteArrayInputStream(recordedSoundArray);
Player p2 = Manager.createPlayer(recordedInputStream,"audio/basic");
p2.prefetch();
p2.start();
} catch (IOException ioe) {
errorItem.setLabel("Error");
errorItem.setText(ioe.toString());
} catch (MediaException me) {
errorItem.setLabel("Error");
errorItem.setText(me.toString());
}

iam trying for recording audio after that playing that.I successed in j2me 2.0 Ktoolbar emulator but in mobile device iam getting problem
below is the code
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.control.RecordControl;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class recordMidlet extends MIDlet implements CommandListener
private Form init = new Form("info");
private Command rec = new Command("rec",Command.OK, 1),
stop = new Command("stop",Command.STOP, 0),
exit = new Command("exit",Command.EXIT, 0);
private byte[] recordedSoundArray;
private Player p;
private RecordControl rc;
private ByteArrayOutputStream output;
public void startApp()
init.addCommand(rec);
init.addCommand(stop);
//init.addCommand(exit);
init.setCommandListener(this);
Display.getDisplay(this).setCurrent(init);
public void pauseApp()
public void destroyApp(boolean unconditional)
class dorecord extends Thread
public void run(){
     try {
init.append("record voice ...\n\n");
// Create a Player that captures live audio.
p = Manager.createPlayer("capture://audio?encoding=pcm&rate=8000&bits=16");
p.realize();
// Get the RecordControl, set the record stream,
rc = (RecordControl)p.getControl("RecordControl");
output = new ByteArrayOutputStream();
rc.setRecordStream(output);
rc.startRecord();
p.start();
} catch (Exception ioe)
init.append(ioe.toString());
class stopplay extends Thread{
public void run(){
try
init.append("finish record... starting playback\n\n");
rc.stopRecord();
rc.commit();
p.stop();
p.close();
init.append("playing...\n");
recordedSoundArray = output.toByteArray();
init.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();
//init.append("finish playing...");
catch (Exception e) {
init.append("stop command: "+e.toString());
public void recordaud()
     new dorecord().start();
public void stopplaying()
     new stopplay().start();
public void commandAction(Command com, Displayable dis)
if(com == exit)
notifyDestroyed();
else if(com == stop)
init.removeCommand(stop);
init.addCommand(exit);
stopplaying();
else if(com == rec)
recordaud();
pls reply to me
[email protected]

Similar Messages

  • HP High Definition Audio Device Code 10 Error -- Causing HDMI Sound Problem

    Hey guys, my laptop is an HP ENVY TouchSmart m7-j010dx Notebook PC, running Windows 8.1.
    When I connect my laptop to my LG Smart TV through HDMI, I cant change the playback device to play the sound from the TV. The HDMI option does not appear in ¨Sound¨.
    When I look in Device Manager, under Sound, video and game controllers; the High Definition Audio CODEC has an error which says (Device status):  
    This device cannot start. (Code 10)
    {Operation Failed}
    The requested operation was unsuccessful.
    I have tried reinstalling and updating the drivers, cleaning and defraging the registry, optimizations etc.
    I followed steps from other posts with similar problem as mine and nothing seems to work, I do not want to reinstall my windows just for this! I am running out of options, I tried everything I could for the past week. I would really appreciate some expert advice.
    Thanks!

    Replied on: http://h30434.www3.hp.com/t5/Notebook-PC-Sound-and-Audio/HP-High-Definition-Audio-Device-Code-10-Err...
    TwoPointOh
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the bottom to say “Thanks” for helping!

  • How do i fix an audio error code 25974?

    how do i fix an audio error code 25974?

    Typically this can be caused by an out of date driver or one that is not fully compatible with the version of OS X that you are using...
    So, which Audio Interface are you using and are you using the latest drivers for that Audio Interface.. and are those drivers compatible with your version of OS X?

  • Core Audio Error Code -2

    Hi -
    I just got my new 2 GHz Core 2 Duo iMac up and running but I don't get any sound from it. The boot chime works, but by the time it is all up there's no sound at all. The speaker icon disappears when I click it and the button for it on the preferences page gets unselected. Another thread said to boot Garage Band for a fix, but that gives me a Core Audio Error Code -2 dialog box. Also, nothing will play in iTunes either. Did any of you ever have this and/or know a way around it?

    You may need to adjust the configuration in Audio MIDI Setup.
    From Mac Help in the Finder Help menu;
    You can use Audio MIDI Setup to configure the audio input and output devices you use with your computer...open Audio MIDI Setup, in Applications/Utilities/Audio MIDI Setup.
    The default setting for Properties For: Built-in Output should be Source: Internal speakers, 44100.0 Hz, 2ch-24bit

  • How to make phone phone vibrate through j2me code

    how to make phone phone vibrate through j2me code
    thanks in advance

    Some like this
    Display.getDisplay(this).vibrate(800);

  • Macbook Pro 13" (Late 2011) - High Definition Audio Device - Code 10

    Hi, i installed Windows 7 Ultimate 64 Bit via Boot Camp on my new Macbook Pro 13" (Late 2011). Driver Disk was installed, but the "High Definition Audio Device" couldn't be started. Status is Code 10. Normal Cirrus Logic Audio is working. Any advice, how this could be fixed? Would be nice, to have audio over the Mini-Displayport HDMI Adapter on Windows as well (Works perfectly with Lion).
    Thanks,
    Thorsten

    Hi, i installed Windows 7 Ultimate 64 Bit via Boot Camp on my new Macbook Pro 13" (Late 2011). Driver Disk was installed, but the "High Definition Audio Device" couldn't be started. Status is Code 10. Normal Cirrus Logic Audio is working. Any advice, how this could be fixed? Would be nice, to have audio over the Mini-Displayport HDMI Adapter on Windows as well (Works perfectly with Lion).
    Thanks,
    Thorsten

  • Not able to compile j2me code

    Hi
    I am new to J2me technology. i downloaded cldc and midp. i have jdk already installed at c:\program files\java\jdk.
    when i try to compile i got error saying not able to find javax.microedition.midlet.* package
    please tell me how to install cldc and midp to run my first program

    Hello
    I would suggest using an IDE for writing the code (like eclipse maybe) and testing it on Sun's Wireless Toolkit which comes already with all the needed libraries.
    Of course you can find all this information by searching google..
    Mihai

  • HP High Definition Audio Device Code 10 Error causing a HDMI sound problem

    Hey guys, my laptop is an HP 350 G2 (L8B07ES), running Windows 8.1. When I connect my laptop to my LG Smart TV through HDMI, I can’t change the playback device to play the sound from the TV. The HDMI option does not appear in ¨Sound¨.When I look in Device Manager, under Sound, video and game controllers; the High Definition Audio CODEC has an error which says (Device status):   This device cannot start. (Code 10){Operation Failed}
    The requested operation was unsuccessful. I have tried reinstalling and updating the drivers, cleaning and defraging the registry, optimizations etc.I followed steps from other posts with similar problem as mine and nothing seems to work, I do not want to reinstall my windows just for this! I am running out of options, I tried everything I could for the past week. I would really appreciate some expert advice.Thanks!

    Thanks iPaYaMi, perhaps a hard reset and then try those steps again.
    Performing a Hard Reset or Forced Reset
    Beyond that, the last thing I can think of, before a recovery would be a BIOS update:
    Updating the BIOS
    HP Notebook System BIOS Update (Intel Processors)
    TwoPointOh
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the bottom to say “Thanks” for helping!

  • No Audio Driver Code 52

    Hello,
    I came back from my High school class, and sat down to chill out after some tiring work.
    I opened up my lid to find my audio driver was missing, I tried all the re installs but to no avail, and I didn't want to factory reset because important work. It was a Code 52 and 2 audio drivers in the control panel had a caution sign on it.
    Help would be appreciated. 

    Also, can you check the following registry key:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96C-E325-11CE-BFC1-08002BE10318}
    At that registry key, in the right window, is there, under "Name", either an UpperFilters or
    LowerFilters value?
    If so, for each of the UpperFilters and/or LowerFilters value, what is listed under "Data"?

  • How to get the external storage card serial no. through j2me code

    hello friends,
    I am developing an application in J2ME, in which i want to know the external storage card information(i.e serial number or its unique id).
    Is there anyway through which i can get this information similar to System.getproperty().
    It is very urgent.
    can someone please help me???????

    Hi Jason,
    I wasn't able to find a C# function that would obtain the serial number for a PXI card. However, I believe you could use the VI_ATTR_MODEL_NAME function to get the model name of the device. Therefore, you would know whether it was the PXI-8430 or the PXI-8431. If this does not work, your workaround will work like you said. I know that this is not your desired way of achieving this, however, it will work. I can continue looking though and see if I can find a function that will return the serial number. 
    Thanks,
    Kevin S
    Applications Engineer
    National Instruments

  • Running J2ME code in a J2SE VM

    Is it possible to use J2ME classes in J2SE? Could I include some jar with, for example, javax.microedition.lcdui.Image, and use that class in a J2SE program? If so, which jar?
    thanks,
    Abraham

    have a look at http://sf.net , they have an emulator for this task...

  • No Audio device Code 10

    Hello all
    I have a HP sv5405 laptop that had a virus. Reinstalled XP from disk as this machine had no recovery partition.
    I downloaded all drivers from HP site but there is no sound card driver available.
    I have downloaded Realtek xp driver and all is installed except Audio device
    Have been to Realtek, Intel with no success. I have uninstalled and reinstalled etc. Would a bios update  fix this problem?
    Why is there no driver on the HP site?
    Where do I get it from? Can Win 7 be loaded? Are there compatable drivers for 7?
    I am pulling my hair out. Can anyone advise as to what to do next before I go bald ?

    Hi:
    We don't want you to go bald so let's see if we can help out! 
    Sometimes you have to download and install the MS UAA driver before you install the audio driver. Did you do that?
    If not, please uninstall your audio driver and install the MS UAA driver for the service pack version of XP you currently have installed.
     MS UAA for XP SP2 , here 
     MS UAA for XP SP3, here
    I cannot find you model anywhere. I did find a zv5405 but not an sv5405.
    Are you sure you have a Realtek audio chip?  I'm assuming you knew this before you had to reinstall XP?
    Using the driver from the Realtek site should work fine.
    Windows 7 capabiltiy...
    Download and run the free MS W7 upgrade advisor which will report if your PC can run W7 or it will report its shortcomings.
    http://windows.microsoft.com/en-us/windows/downloa​ds/upgrade-advisor
    Hope this helps,
    Paul

  • Onkyo Audio Receiver Codes

    I have an Onkyo Receiver Model TX-SR606. I'm looking for the correct code to program my Verizon remote. There are 20 codes that I know of. Some of the codes turn on the receiver, but don't turn it off AND some of the codes turn off the receiver, but don't turn it on. Am I missing something?

    You're not missing anything.  The FiOS remote is too limited.  Onkyo receivers only have discrete ON and OFF functions, they do not have a single command that will toggle the power.  Unfortunately, the FiOS remotes do not have in their l;ibraries any way to deal with this. Your best bet is to get a third party iuniversal remote, like from Radio Shack, One-for-all, or Harmony, if you want to go a little bit more upscale.
    You're still going to have to work a little bit to add the required functions, but at least some of these remotes allow that, while the FiOS remote does not.

  • Locking the phone using J2me codes

    I am working these day to develop and application using J2me , that has the ability to lock the phone using it is own password.
    but i am asking is it possible to lock the phone using J2me commands??

    Thank you for your response
    but do you know what libraries (API) to use if using C++ with mobile phones.

  • J2me Code Signing:Self Signed Certificate VS Unknown Certificate VS No Cert

    Hello all,
    I have Developed a j2me Application which i want to digitally sign with a Certificate
    that i am going to buy from Verisign.The application is simply doing http/https connections.
    My questions are:
    (1) Which tool should i use? WTK 2.5.2 signing tools or something else like openssl?
    (2) In which Security domain should i include My certificate? identified_third_party or something else?
    Additionally lets say that the Phone in which i am going to install my application for some reason does NOT
    CONTAIN the appropriate ROOT Certificate from Verisign (in which belongs the certificate that i will buy)
    The (Crucial) Questions are:
    (A)What will happen if i will try to install my signed Midlet in a handset not containt Verisign Root Certificate?
    will be installed or no installation at all will take place?
    (B)What will happen if i sign my Midlet with one a "Self Signed" Certificate and install it to my Handset?
    Finally what must be my decision for Handsets that do not include the Appropriate Verisign ROOT Certificate?
    (a)Sign My Application with the Certificate that i will buy From Verisign?
    (b)Sign My Application a "Self Signed" Certificate?
    (c)Do not Sign the application at all?
    (d)Buy A second Certificate from another CA authrity ie thawte
    Please HELP!
    Thanks
    NiKolaos

    (1) Which tool should i use? WTK 2.5.2 signing tools or something else like openssl?
    (2) In which Security domain should i include My certificate? identified_third_party or something else?Did you check the WTK User Guide ? In my version WTK (2.5.1), guide contains quite a large chapter *"Security and MIDlet Signing"* explaining how to use various WTK utilities.
    As far as I can tell, this chapter in particular describes how to emulate real world usage with WTK, for example how to create a key pair and sign a MIDlet (for testing purposes only) and how to emulate real world certificates management (again, for testing purposes).
    This chapter also describes toolkit procedure for signing MIDlet suites with real keys and how to import certificates.
    Chapter also contains sections explaining security policies and protection domains.

Maybe you are looking for

  • Loading an external movie clip

    Hi team,   Last time I wanted to load an external clip I could do it like this on (release) {           unloadMovieNum(1);           loadMovieNum("whatever.swf",1); So now I want to achieve exactly the same thing in AS3, I have been looking at exampl

  • No signal HELP ASAP

    I've had no signal last 4 days! I got a new sim yesterday from ee because thought my old sim just broke. New sim worked fine last night till this morning and again no signal! Just says not registered on network! But I was making calls last night! Why

  • Is an iTrip for video signals possible?!

    ...because if it is, i'm sure it's in the works - - who knows about wireless video transmissions? how nice would that be to be able to just connect to TV and Radio wirelessly and have instant surround sound video - now that'd be an impressive transmi

  • Student.

    hello, I'm studying to upgrade my MSCA on windows server 2012 and so I set up a lab at home using Virtual box and created a Domain.local and it is working fine.  Now I'm trying to create a child domain but getting an error that says the following " "

  • DRM for Windows Media Player on the ipod

    My ipod is worthless, if it can't play files with DRM for Windows Media Player. My library, that offers this files for download says, it would cost 50.000 dollars to provide also ipod-compatible files. Because they can't spend this money, I will need