java - Issues with playing sounds on the BlackBerry -
I am having the following problem while playing the sound on Blackberry:
- The application is hanged for ~ 500 ms (not when the player is created, when the sound is actually played)
- There is a delay rather than the call and the voice
I tested on a physical device other than the simulator. On the simulator, there should be a bug, because this v Seconds before the car starts (I've heard that it is a problem with the simulator, so ...).
I have also tested. Wav vs mp3 files, and it gives pretty much the same results.
Here is the code I use to load a player:
stream = new object (). GetClass () GetResourceAsStream (fileName); Results = javax.microedition.media.Manager.createPlayer (stream, fileName.endsWith (".wav")? "Audio / x-wave": "audio / mpeg"); If (prefetch) {result.prefetch (); }
I then store the player reference, which I use to run the sound with the following code:
javax.microedition. Media.player player = (Javax.microedition.media.Player) resource [soundId]; If (player! = Null) {// # debug System.out.println ("Player state:" + .getState (+) player;); If (player .getState ()! = Javax.microedition.media.Player.STARTED) {player.setLoopCount (LoopCount); Player.start (); }}
I feel positive that due to delay the sound is playing because I have a switch to close it and when I do this the delay is gone. Is there something I am doing wrong?
Updates
Nothing worked, so I stopped changing the sound into MIDI files which are handled better if any solution Finds, even then I would like to hear it.
There is no good solution for the problem, but how to reduce it:
- Create a separate thread to run sounds (this is a thread that will call players. Start (), because this
- if your game's frame rate is too high and As a result you are using 100% CPU, then the media player will not have enough time to prepare the buffer between the frame, For help, it will take a long time to run. Reduce the frame rate slightly to help.
- At the developer conference, RIM showed the code for a wave mixer, a player joining the incoming sound files in the stream. Keeping open should fix the problem, although they have not released the code yet.
- On OS7, under high CPU load, mess with MIDI file frame rate, so avoid it. < / Li>
Comments
Post a Comment