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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
GMofOLC
Posts: 11
Registered: ‎06-11-2009
Accepted Solution

Can't play a user selected audio file

I'm having problems getting a user selected audio file to play. I know you can't play the ones RIM supplies, but here's what I have:

 

Class cl = Class.forName("bb.cen.CallEnd");
InputStream input = cl.getResourceAsStream(soundToPlay);

m_player = Manager.createPlayer(input, "audio/mpeg");

m_player.realize();

m_player.prefetch();

 

 

soundToPlay is gotten from:

 

soundToPlay = "file:///" + oData.getStringElement(OptionsData.USERSOUND);

 

OptionsData.USERSOUND is gotten from a file selection popup screen using getFile().

It is usually something like /SDCard/Blackberry/ringtones/sound.wav

 

Whenever I run it though, I can select the file, but I always get a 

FRIDG:  cannot find......

I know I'm getting this because getResourceAsStream is returning null.

How do I get it to not return null?

 

 

Please use plain text.
Developer
rcmaniac25
Posts: 1,789
Registered: ‎04-28-2009
My Carrier: Verizon

Re: Can't play a user selected audio file

getResourceAsStream gets a file that is built into a RIM app. soundToPlay goes to a file location, try passing soundToPlay into Manager.createPlayer instead of trying to get it **bleep** a embedded resource. If it is a embedded resource then you need to access it like you do with Class.forName only you pass the String into getResourceAsStream.

 

Hope that makes sense.

------------------------------------------------------------
Three simple rules:
1. Please use the search bar before making new posts.
2. Kudo posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
New Developer
GMofOLC
Posts: 11
Registered: ‎06-11-2009

Re: Can't play a user selected audio file

Yessiree bob. That did the trick.

Thank you.

 

I'm just confused as to why they would provide a method that lets you get files that you can't even use....

Please use plain text.