Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-06-2008, 12:34 PM
JSK JSK is offline
Member
 
Join Date: Nov 2007
Posts: 3
JSK is on a distinguished road
Re-playing sound
Hi guys, I'm writing a J2ME game and I want a sound (midi) to play every time the player picks up a bonus Natural way to do this, I thought, was to prepare all the resources somewhere at the loading stage, create a sort of 'sound-player' object and use it repeatedly throughout the game. So I came across javax.microedition.media.Player. The manual suggests it releases it's resources after playback and therefore shouldn't be used more than once. I came up with a temporary solution like:
initResources() {
...
tone1 = this.getClass().getResourceAsStream("/my_tone.mid");
tone1.mark(0);
...
}

playSound() {
...
tone1.reset();
pl1 = Manager.createPlayer(tone1, "audio/midi");
pl1.start();
...
}

It works, but I don't like the idea of creating a new player and having it fetch the stream each time, say, a snake eats an apple. So what's the right way to prefetch and re-use sounds?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nokia 5300 freezes when playing sound after receiving a call presto CLDC and MIDP 2 10-31-2007 04:55 PM
Playing sound in applet?????? Bagesh Java Applets 2 07-13-2007 05:46 PM
Playing Mp3 in a Mobile phone luisarca CLDC and MIDP 1 06-23-2007 06:20 PM
Playing Mp3 in a Mobile phone luisarca Sun Java Wireless Toolkit 0 06-21-2007 11:17 AM


All times are GMT +3. The time now is 10:28 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org