Go Back   BlackBerry Forums at CrackBerry.com > BlackBerry Professionals > Developer's Forum

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-14-2009, 02:22 PM
CrackBerry User
Device Model: 9000 (Bold)
Carrier: Rogers
 
Join Date: Apr 2009
Posts: 20
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
  #2  
Old 04-17-2009, 04:17 PM
papped's Avatar
CrackBerry Genius of Geniuses
Device Model: Pre
Carrier: Sprint
 
Join Date: Sep 2008
Posts: 6,346
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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



 
 Site Support | Accessory Order Support | App Store Support | Advertise | Newsletter | About Us

Creating smartphone communities
Android Central - Android reviews, news and forums Crackberry - Blackberry news, reviews and community TiPb - iPhone news, accessory reviews & forums
Pre Central - Palm Pre Review, News and Community Treo Central - Treo & Centro News and Forums WMExperts - Windows Mobile Reviews & News

The names RIM and BlackBerry are registered Trademarks of Research in Motion Limited.
CrackBerry.com is in No Way Affiliated with Research in Motion Limited.
Copyright ©2007-2009 Smartphone Experts. Terms and Conditions. Privacy Policy. All rights reserved.