Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Trusted Contributor
Posts: 151
Registered: ‎07-20-2010
My Device: Not Specified
Accepted Solution

Playing audio once its recorded

Can anyone tell me how I should play a recorded audio? I am recording it in the default AMR format. The data is stored in a byte[] array. Now i want to play this data once the recording is finished. Please can someone give me a sample code of how this could be done.

My code is,

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


rcControl = (RecordControl) player.getControl("RecordControl");

output = new ByteArrayOutputStream();





Once I hit the stop button, it does the following:


data = outout.toByteArray();




Now, When i hit the play button,

player = Manager.createPlayer(new String(data));  Note: data is a byte array

player. realize();




But when I hit the play button, the player doesnt play this data. Can someone please help me with this. I am really stuck with this. Can someone give me a code for playing this recorded audio? Thanks.












Posts: 35
Registered: ‎02-11-2010
My Device: curve 8900

Re: Playing audio once its recorded

I didn't try this but I think it goes something like this:


(data is byte[])


ByteArrayInputStream bi = new ByteArrayInputStream(data );

player = Manager.createPlayer(bi, "audio/amr");

Trusted Contributor
Posts: 151
Registered: ‎07-20-2010
My Device: Not Specified

Re: Playing audio once its recorded

Thank you very much, it worked.

New Contributor
Posts: 6
Registered: ‎02-20-2012
My Device: Blackberry torch
My Carrier: simulator

Re: Playing audio once its recorded

Hi frnz,


I'm also trying to achieve something like this.

Only difference is i want to save the recording to a file.


Please tell me what i write on click event of 'Stop & Save' button.


Thanks in adavance.

Posts: 36
Registered: ‎10-12-2012
My Device: developer
My Carrier: developer

Re: Playing audio once its recorded

can anyone pls help me with the code for audio recording and playing....