aspose file tools*
The moose likes Beginning Java and the fly likes mmm.. music Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "mmm.. music" Watch "mmm.. music" New topic
Author

mmm.. music

Matt Fyffe
Greenhorn

Joined: Jun 19, 2003
Posts: 25
Music, the beauty of life (well not really) has expressed a desire to enter into my program. I am going to have a song playing in the background for my program and my question is, how do I make it so it's not the direct address of the file? I managed to finally get it with images using this code:

So how do I have music work with the same simplified address location? I found a way to play my song in the prog in an example in my friends book so here's the code I used if it need's to be referenced to. Also, is there an easier way to make the music play in the background? I hate threads lol. Thanks for all help you guys can and do provide me with everytime i bother you.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I'm assuming that you want the following line to use a relative location.
new File("c:/programming/Rpg/Ink_Spots-I_Don't_Want_To_Set_The_World_On_Fire.wav");
Note that a File object doesn't have to be constructed using an absolute file location. Working from my K:/java/temp directory, the following code snippet prints true.Placing the Foo.java file in a subdirectory named fubar, and changing the source code as follows also results in true.
[ July 11, 2003: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Matthew Fyffe
Greenhorn

Joined: Jul 11, 2003
Posts: 16
Hmmm... as I can't seem to access my account Matt Fyffe right now (it no longer recognizes it :-\) I'll use this for now.
I tried doing the same thing you did, however I got this message when I ran my program :-\.
java.io.FileNotFoundException: Ink_Spots-I_Don't_Want_To_Set_The_World_On_Fire.wav (The system cannot find the file specified)
If I offer the exact address it play's the song no problem at all. :-\/
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Which line of code is causing the exception?
Matthew Fyffe
Greenhorn

Joined: Jul 11, 2003
Posts: 16
it doesn't say it when i compile, it compiles ok and runs fine but in a Terminal Window that comes up when I run my program says that message in it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: mmm.. music