Audio Clip applet...

Hi,
I wanted to run a java audio-clip applet but cannot do it!!
I have a .java file that does not compile!! Here is the .java file(I simply want to run a .au file!):
Please let me know how to fix it...
Thanks,
saurav

***********SndPlay.java***************
import java.applet.AudioClip;                            
public class SndPlay extends Applet                                
{                                                                  
Audioclip sound = null;                                            
                                                                   
public void init()                                                  
{                                                                  
        String soundName;                                          
        soundName = getParameter("sound");                          
        if(soundName == null)                                      
        return;                                                    
                                                                   
        sound = getAudioClip(getCodeBase(),soundName);              
}                                                                  
public void start()                              
{                                                
        if (sound != null) sound.play();        
}                                                
                                                 
public void stop()                              
{                                                
        if (sound != null) sound.stop();        
}                                                
                                                 
}                                                
************************************

*******SndPlay.html***************
 <html>                                              
<applet code=SndPlay.class width=15 height=15>    
<param name=sound value="scooby.au"></applet>        
</html>                                                                              ***********************************              
                                                 
sauravAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

andyhedgesCommented:
Change the first line to

import java.applet.*;

it will then compile. I think. I haven't got a complier on this machine to try it.
0
expertmbCommented:
hi,
visit this

http://www.bome.com/JaWavedit/

mb...
0
vladi21Commented:
import java.applet.AudioClip;
import java.applet.Applet;
public class SndPlay extends Applet
{
AudioClip sound = null;

public void init()
{
        String soundName;
        soundName = getParameter("sound");                          
        if(soundName == null)
        return;                                                      
                                                                     
        sound = getAudioClip(getCodeBase(),soundName);
}                                                                    
public void start()
{                                                
        if (sound != null) sound.play();          
}
                                                 
public void stop()
{                                                
        if (sound != null) sound.stop();
}

}


You can find working examples at
http://java.sun.com/docs/books/tutorial/applet/appletsonly/sound.html

also look
how to use the Java Sound engine in JDK 1.2
http://www.java.sun.com/docs/books/tutorial/sound/index.html


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

andyhedgesCommented:
vladi21 this is just long hand for what I proposed. JDK will not import class that are not need. This way of doing it only servers to document what you have used for particularly long pieces of code.

I can not believe you proposed this as an answer.
0
vladi21Commented:
andyhedges : What about
Audioclip sound = null;                                        
                                        and                            

AudioClip sound = null;

?
0
andyhedgesCommented:
Fair point.. comment revoked...

But could have pointed it out.

(Damn I would have noticed that if I had a compiler).

Andy
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.