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

BlackBerry® World™ Development

Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

problems with Playing audio files Simultaneously


 Hi all,

            when am trying to play two audio files it is giving errors. the details are as follows...


    am working with BB strom,  4.7.0 version. for my application i need to play audio files at a time. 1 file as background through out the app and the other at the random positions. when i tried to play them separately the audio is  playing ensuring that the code is correct and the file formats are also supportable.

                  am using .wav file for background file and .mp3 file for the foreground file. on a particular button click i need to invoke the mp3 file where i need to hear audio of the both  files. 


                   the following is the code snippet please suggest me teh solution how to fix these two.

/**** code for the audio playing ***/ public class Audio extends Thread { private Class clazz; private InputStream is; private Player player; String audiofile; private int fileType; public Audio(String path, int type) { audiofile = path; fileType = type; } public void run() { //this sample demonstrates playing an MP3 file that has been //added as a resource to the project try { //retrieve the MP3 file clazz = getClass(); //create an instance of the player from the InputStream is = clazz.getResourceAsStream(audiofile); // 1-- mpeg, 2-- wav audio files if(fileType == 1) player = javax.microedition.media.Manager.createPlayer(is, "audio/mpeg"); else if(fileType ==2) player = javax.microedition.media.Manager.createPlayer(is, "audio/x-wav"); player.realize(); player.prefetch();

if(count == 1){ player.setLoopCount(-1);

} // count used to make the background to play infinetly player.start(); } catch (Exception ex) { System.out.println(ex.getMessage()); } } }



LoadingScreen() { at = new Audio("/neon1.wav",2); at.start(); }// calling the background file. similarly under the button click but a different file



Thanks and Regards,