[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Audio Clip applet...

Posted on 1999-12-22
6
Medium Priority
?
297 Views
Last Modified: 2013-11-23
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>                                                                              ***********************************              
                                                 
0
Comment
Question by:saurav
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:andyhedges
ID: 2300108
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
 
LVL 6

Expert Comment

by:expertmb
ID: 2300407
hi,
visit this

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

mb...
0
 
LVL 7

Accepted Solution

by:
vladi21 earned 160 total points
ID: 2300723
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 1

Expert Comment

by:andyhedges
ID: 2300735
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
 
LVL 7

Expert Comment

by:vladi21
ID: 2300750
andyhedges : What about
Audioclip sound = null;                                        
                                        and                            

AudioClip sound = null;

?
0
 
LVL 1

Expert Comment

by:andyhedges
ID: 2300754
Fair point.. comment revoked...

But could have pointed it out.

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

Andy
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question