Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  adding sound!  (Read 1946 times)
0 Members and 1 Guest are viewing this topic.
Offline pistachiomonkey

Senior Newbie




Java games rock!


« Posted 2005-04-04 14:34:15 »

i am trying to add sound to my game and have found this implementation

try {
InputStream is = getClass().getResourceAsStream("song.mid");
Player audioPlayer = Manager.createPlayer(is, "audio/midi");
audioPlayer.start();
} catch (IOException ioe) {
} catch (MediaException me) { }

problem is i keep getting a compliation error pointing to the 'is' in the second line with the manager, saying its an incompatible type. i have imported java.io, util, the microedition.media and media.control, where am i going wrong?

any ideas?

cheers
beta test the current game @
www.pistachiomonkey.com
Offline davidaprice

Junior Member





« Reply #1 - Posted 2005-04-05 05:15:17 »

I can't see any problems - my code looks just like yours and works. Try downloading and building Forum Nokia's MIDP 2.0 game example "Sheepdog", which contains similar code; if you can't get that to build, you'll know the problem is in your build tools or environment.

Beware of using relative filenames like "song.mid" in getResourceAsStream (or Image's createImage) - you're more likely to succeed by always using absolute filenames like "/song.mid".
Offline pistachiomonkey

Senior Newbie




Java games rock!


« Reply #2 - Posted 2005-04-05 12:48:37 »

thank you david, once again!

i have downloaded and complied the sheepdog example with success, and refrenced the midi file appropriatly but i continue to get an incompatible type error pointing to the use of 'is' on the Manager.createPlayer?? it says required type is Player?

have also made sure that i am importing the media API, aggghh  Shocked

so frustrted with this as it seems so easy?

any other pointers guys?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline davidaprice

Junior Member





« Reply #3 - Posted 2005-04-06 05:09:19 »

Please could you show us the exact text of the error message?
Offline pistachiomonkey

Senior Newbie




Java games rock!


« Reply #4 - Posted 2005-04-06 13:24:37 »

cheers David,

here's the returned complier build errors:

C:\WTK22\apps\Monkey Madness\src\MadnessMIDlet.java:434: incompatible types
found   : javax.microedition.media.Player
required: Player
      Player audioPlayer = Manager.createPlayer( is , "audio/midi");
                                               ^(this hat apperas under the 1st paranthases'(')
C:\WTK22\apps\Monkey Madness\src\MadnessMIDlet.java:435: cannot resolve symbol
symbol  : method start ()
location: class Player
      audioPlayer.start();
                 ^(this hat apperas under the first dot .)
2 errors
com.sun.kvem.ktools.ExecutionException
Build failed

here are my imports:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import javax.microedition.rms.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import java.util.*;
import java.io.*;

um the method that does this call is in the MIDlet. is there any other info you need to diagnose this situation

many thanks for your time

Nick
Offline davidaprice

Junior Member





« Reply #5 - Posted 2005-04-07 05:53:35 »

Does your own source code include a class called Player? Perhaps representing your game's user? Maybe the compiler thinks that "Player audioPlayer" is this kind of Player, not the javax.microedition.media.Player kind? If so, the solution is to write:

 javax.microedition.media.Player audioPlayer = <etc...>
Offline pistachiomonkey

Senior Newbie




Java games rock!


« Reply #6 - Posted 2005-04-07 14:08:20 »

david you are a true legand!

my monkey can now battle to the sweet guitar rifts of Luarance Juber's pass the buck! simply sensational! Grin
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (39 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (25 views)
2014-08-16 06:20:21

Tekkerue (36 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!