MEMORIAL DAY SALE: Save 15% on ALL BlackBerry Accessories! Use Coupon Code MEM12.
Join Our 3 MILLION+ Members Today! Register Here | Login
Go Back   BlackBerry Forums at CrackBerry.com > BlackBerry Professionals > App Developers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
    Thread Author   #1  
Old 04-14-2009, 12:22 PM
CrackBerry Abuser
Device(s): 9000 (Bold)
Carrier: Rogers
 
Join Date: Apr 2009
Posts: 169
Likes Received: 21
Thanked 18 Times in 4 Posts
Default Playing Sounds in J2ME .. quicker?

I'm using basic code to play sounds inside of my project.

public void playsnd() {
try {
InputStream is = getClass().getResourceAsStream("/res/test.wav");
Player p = Manager.createPlayer(is, "audio/x-wav");
p.prefetch();
p.start();
}
catch (IOException ex) {}
catch (MediaException ex) {}

}

The problem I'm having is that I have 4 sounds that I want to play, in progression, and they always seem to be "lagged" whenever I try to load them.

Is there a way to load the player / sound when you start the app and then just play them so they dont' have to load everytime you want to play them?
Reply With Quote Tip this Post
  #2  
Old 04-17-2009, 02:17 PM
CrackBerry Genius of Geniuses
Device(s): 9900
Carrier: Tmobile
 
Join Date: Sep 2008
Posts: 14,982
Likes Received: 416
Thanked 335 Times in 269 Posts
Default

1) Do the 4 sounds need to be separate files? If they always play in progression you could combine them.

2) Theoretically you could create multiple players and prefetch them on load, then just call player1.start() instead of the entire playsnd(). I haven't messed with that much though.
__________________
My website http://papped.webatu.com
Reply With Quote Tip this Post
Reply
BlackBerry Forums at CrackBerry.com > > BlackBerry Professionals > App Developers   Playing Sounds in J2ME .. quicker?

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes