Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (111)
games submitted by our members
Games in WIP (553)
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  
  reading wav files located in in a jar file  (Read 2725 times)
0 Members and 1 Guest are viewing this topic.
Offline zero

Junior Member





« Posted 2005-06-23 23:17:40 »

Hi all,

is there any way to load a .wav from a jar file or input stream using ALut ?
I am asking because the method alutUnloadWAV only accepts a string.
Or is there a trick to convert the resource url to a string, that can be used?
I tried the following, but it didn't work. Sad

java.net.URL url = ClassLoader.getSystemResource("MySound.wav"); 

// works well
java.io.InputStream in = url.openStream();
in.read();
...
in.close();           

// but I can't use the file location as an argument to an FileInpuStream -
the exception:thrown, is listed below

ALut.alutLoadWAVFile( url.getFile(), ..);


java.io.FileNotFoundException: file:/home/gestalt/code/projects/beergarden/dist/beergarden.jar!/FancyPants.wav (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at com.sun.media.sound.WaveFileReader.getAudioInputStream(WaveFileReader.java:205)
        at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1162)
        at net.java.games.joal.util.WAVLoader.loadFromFile(WAVLoader.java:76)
        at net.java.games.joal.util.ALut.alutLoadWAVFile(ALut.java:101)
        at net.monoid.beergarden.RendererAL.loadALData(RendererAL.java:138)
        at net.monoid.beergarden.RendererAL.<init>(RendererAL.java:77)
        at net.monoid.beergarden.Main.main(Main.java:34)

Offline zero

Junior Member





« Reply #1 - Posted 2005-06-27 00:06:29 »

After I have looked at the source code, I noticed that the problem easily could be solved, because:

The method ALut.alutLoadWAVFile(String  filename, ..) forwards the 'filename' variable to theWAVLoader.loadFromFile(String  filename, ..) and this creates a File object, which is passed to AudioSystem.getAudioInputStream(..). Since this method is overloaded for an InputStream and a URL, the ALut and WAVLoader classes could be updates easily.

Please do so, because otherwise I can't use these utilities with java webstart.

Best regards
-Michael
Offline gregof

Junior Member




in code we trust


« Reply #2 - Posted 2005-06-28 21:21:33 »

I second that!, I actually had the exact same problem and came to the same solution  Cheesy

// Gregof
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline BrackishWater

Senior Newbie




I love YaBB 1G - SP1!


« Reply #3 - Posted 2005-12-28 19:37:05 »

couldn't you just write your own loader and pass the bytes off to JOAL in some fashion?
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #4 - Posted 2005-12-28 20:06:18 »

If you check out the gluegen-branch-1-0 sources of the JOAL tree this has already been implemented:
1  
cvs co -r gluegen-branch-1-0 joal


However you'll still need to build this source tree yourself which is a little involved since it requires a built JOGL workspace alongside it. Next week we'll promote this work to the main trunk and set up nightly builds for JOAL to save you this trouble.

I still need to make such a branch for the joal-demos workspace. I'll try to do that today.
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #5 - Posted 2005-12-28 20:25:48 »

OK, the gluegen-branch-1-0 branch is there for the joal-demos workspace so you can just add "joal-demos" to the end of the cvs co line above to see examples of the new APIs. If you want I could put up builds for a couple of platforms to hold you over until the nightly builds are up; let me know which platforms.
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.

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

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

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

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

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

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

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

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (33 views)
2014-08-08 02:01:56

Norakomi (42 views)
2014-08-06 19:49:38
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!