Welcome!

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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
New Developer
Posts: 22
Registered: ‎06-16-2010
My Device: Z10
My Carrier: Rogers

Play Audio File on Blackberry

Hello,

I am trying to play a wav file on the blackberry and the debug is not giving me an Exception to work with.  I have imported the wav file ('notify.wav') into my project as a resource (in the 'res' folder).  Below is the snippet of code that should play the audio file, but there's no sound when I invoke the method.

 

try{

InputStream inptstrm =getClass().getResourceAsStream("/res/notify.wav");

Player p = javax.microedition.media.Manager.createPlayer(inptstrm, "audio/x-wav");

p.realize();

VolumeControl volume = (VolumeControl)p.getControl("VolumeControl");

volume.setLevel(99);

p.prefetch();

p.start();

}

catch(Exception me){

}

 

I suspect my issue is with the import and finding where the file is to play.

Any assistance would be greatly appreciated.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Play Audio File on Blackberry

Agree finding the input file is the trick.

 

Don't think you need the res, just try

....getResourceAsStream("/notify.wav");

 

Do put some System.out.println(..) output in your exception handler too.