Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Creating Jar from Applet on: 2007-07-24 02:53:02
Ok, I think I got everything figured out. I am having a problem with this one method used to play my audio files:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
public void loadAu(String filepath)
    {
        try
        {
           InputStream in = getClass().getResourceAsStream(filepath);
           AudioInputStream stream = AudioSystem.getAudioInputStream(in);
           AudioFormat format = stream.getFormat();
           if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED)
           {
                 format = new AudioFormat(
                    AudioFormat.Encoding.PCM_SIGNED,
                    format.getSampleRate(),
                    format.getSampleSizeInBits()*2,
                    format.getChannels(),
                    format.getFrameSize()*2,
                    format.getFrameRate(),
                    true);
                 stream = AudioSystem.getAudioInputStream(format, stream);
           }
   
           DataLine.Info info = new DataLine.Info(
            Clip.class, stream.getFormat(), ((int)stream.getFrameLength()*format.getFrameSize()));
           clip = (Clip) AudioSystem.getLine(info);
           clip.open(stream);
           clip.addLineListener(this);
           stream.close();
   
        }
        catch (MalformedURLException e){e.printStackTrace();}
        catch (IOException e){e.printStackTrace();}
        catch (LineUnavailableException e){e.printStackTrace();}
        catch (UnsupportedAudioFileException e){e.printStackTrace();}
    }


It throws an IOException when It is in a jar and when I call it with the parameter "Audio/file.au" Audio being the subdirectory and Audio.au being the audio file. It works when I use it in Bluej or in Eclipse. This is the exact error:

1  
2  
3  
4  
5  
6  
7  
java.io.IOException: mark/reset not supported
   at java.util.zip.InflaterInputStream.reset(Unknown Source)
   at java.io.FilterInputStream.reset(Unknown Source)
   at java.io.FilterInputStream.reset(Unknown Source)
   at com.sun.media.sound.WaveFileReader.getFMT(Unknown Source)
   at com.sun.media.sound.WaveFileReader.getAudioInputStream(Unknown Source)
   at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)
2  Game Development / Newbie & Debugging Questions / Creating Jar from Applet on: 2007-07-23 01:49:22
I made an applet and I want to stick it in a jar but I guess there is no way to execute the jar because the applet does not have a main method. Is there another way to make another class with a main method that just executes the applet?
Also, I want to use proguard to obfuscator my applet. Can I use it without being able to make a jar file out of my applet?

Thanks
3  Game Development / Newbie & Debugging Questions / Need to pause key listener on: 2007-07-18 22:27:46
I am making an game and when a player attacks, I want to play a sound. I am stuck trying to pause the key listener while the sound is being played. This is what I want to do...
if player attacks, play sound,
if a key is pressed check if sound is playing, if not then execute...
... but I can't find any methods to check if the sound is playing. I tried just pausing the thread for the length of the sound but it doesn't pause the key listener and just seems like poor coding.
I am using AudioClip to load and play the sound.
Any advice would be greatly appreciated.
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

Riven (20 views)
2014-07-29 18:09:19

Riven (13 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (31 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (28 views)
2014-07-23 21:07:15

Riven (29 views)
2014-07-23 20:56:16

ctomni231 (60 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!