09-05-2009 11:06 PM
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?
Solved! Go to Solution.
09-05-2009 11:42 PM
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.
09-06-2009 01:26 AM
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....