Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Java Help
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Dom




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Wed Jan 08, 2014 7:48 pm   Post subject: RE:Java Help

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




PostPosted: 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?
Dom




PostPosted: 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.
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: