Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (687)
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 2282 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");
} 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, util, the and media.control, where am i going wrong?

any ideas?

beta test the current game @
Offline davidaprice

Junior Devvie

« 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 Devvie

« 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\ incompatible types
found   :
required: Player
      Player audioPlayer = Manager.createPlayer( is , "audio/midi");
                                               ^(this hat apperas under the 1st paranthases'(')
C:\WTK22\apps\Monkey Madness\src\ cannot resolve symbol
symbol  : method start ()
location: class Player
                 ^(this hat apperas under the first dot .)
2 errors
Build failed

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

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

Offline davidaprice

Junior Devvie

« 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 kind? If so, the solution is to write: 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.

Dwinin (70 views)
2015-11-07 13:29:08

Rems19 (80 views)
2015-10-31 01:36:56

Rems19 (72 views)
2015-10-31 01:32:37

williamwoles (106 views)
2015-10-23 10:42:59

williamwoles (92 views)
2015-10-23 10:42:45

Jervac_ (106 views)
2015-10-18 23:29:12

DarkCart (134 views)
2015-10-16 00:58:11

KaiHH (116 views)
2015-10-11 14:10:14

KaiHH (155 views)
2015-10-11 13:26:18

BurntPizza (169 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 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‑
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!