Computer Science Canada

Java Help

Author:  Dom [ Wed Jan 08, 2014 7:33 pm ]
Post subject:  Java Help

// The "Sound" class.
import java.awt.*;
import hsa.Console;

import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.spi.AudioFileReader;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.sound.sampled.LineUnavailableException;


public class Sound
{
static Console c; // The output console

public static void main (String[] args)
{
c = new Console ();

sound ();


} // main method


public static void sound ()
{
try
{
AudioInputStream audio;
audio = AudioSystem.getAudioInputStream (this.getClass ().getResource ("Deal Or No Deal Full Theme Song.wav"));
javax.sound.sampled.Clip clip = AudioSystem.getAudioInputStream (java.io.File $1);
clip.open (audio);
clip.start ();
}
catch (UnsupportedAudioFileException uae)
{
}
catch (IOException ioe)
{
}
catch (LineUnavailableException lua)
{
}
}
} // Sound class



I am working with Ready To Program with Java. I am using HSA consoles. Everything seems to be working except one line:

javax.sound.sampled.Clip clip = AudioSystem.getAudioInputStream (java.io.File $1);

where the program is giving me an error with "$1" (it is highlighting only the "$1"). There are no other errors in the program. I am trying to get sound to play when I run the program.

Author:  Raknarg [ Wed Jan 08, 2014 7:48 pm ]
Post subject:  RE:Java Help

Why is there a "$1" in the first place?

Author:  DemonWasp [ Wed Jan 08, 2014 7:49 pm ]
Post subject:  RE:Java Help

Please use either [ syntax = "java" ] or [ code ] blocks to post readable code in the future.

What are you expecting that line to do? Where did you see an example with java.io.File $1 as a function argument?

Author:  Dom [ Thu Jan 09, 2014 2:12 pm ]
Post subject:  RE:Java Help

Ready To Program told me to do that. What should I place there instead?

The file I am trying to play is called

Deal Or No Deal Full Theme Song.wav.

Author:  Tony [ Thu Jan 09, 2014 2:34 pm ]
Post subject:  Re: RE:Java Help

Dom @ Thu Jan 09, 2014 2:12 pm wrote:
Ready To Program told me to do that.

Link to that documentation please.


: