I'm desperately trying to get my soundboard application to work. I have a GridView consisting of Buttons, which have an OnClickListener starting the sound file associated with the button. The sound files are stored as MP3 audio files in the res/raw folder and are referenced using the R class.
The following problem only occurs when running the app on a real device, however, on the emulator it works perfectly. I have tried two different HTC Hero so far.
I have a mysterious problem, that everytime I press a button to play a specific sound, ALL sounds in the res/raw folder are played in the order they are listed there. My current code to play a sound looks like this:
Using java Syntax Highlighting
- if (player != null) {
- player.stop();
- player.release();
- }
- player = MediaPlayer.create(this, resId);
- if (player != null) {
- player.start();
- }
Parsed in 0.029 seconds, using GeSHi 1.0.8.4
As you can see I use a "singleton" MediaPlayer to play the files. I have also tried using a new separate MediaPlayer instance for each sound file, with the same result. Additionally, I have tried playing the sound file in a separate thread with the result, that only the first time all sound files are played. After that the buttons work as intended.
Thanks for your help!
Adrian


