File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes MID player applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "MID player applet" Watch "MID player applet" New topic

MID player applet

vikram kamath c

Joined: Jun 20, 2009
Posts: 15
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class PlaySoundApplet1 extends Applet implements ActionListener{
Button play,stop;
AudioClip audioClip;

public void init(){
play = new Button(" Play in Loop ");
stop = new Button(" Stop ");
audioClip = getAudioClip(getCodeBase(), "20.mid");

public void actionPerformed(ActionEvent ae){
Button source = (Button)ae.getSource();
if (source.getLabel() == " Play in Loop "){;
else if(source.getLabel() == " Stop "){

is my code
it works on applet viewer but not on html please help
pete stein

Joined: Feb 23, 2007
Posts: 1561
Don't compare Strings with == but instead use the equals(...) method. i.e.,

Also, are you sure that your applet is finding your 20.mid file? I know that with JApplets we generally get this information via resources, not files.
vikram kamath c

Joined: Jun 20, 2009
Posts: 15
i see 20.mid loading through the console(for html).but does not come .As i Said before it works fine in APPLET VIEWER but not in HTML only thanks.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Do you see the file "20.mid" being requested in the web server logs? Does it have permissions to be served to the world?
vikram kamath c

Joined: Jun 20, 2009
Posts: 15
How do i see that? i did not understand. its not in server just clicking on the HTML file of the applet during loading.THANKS
I agree. Here's the link:
subject: MID player applet
jQuery in Action, 3rd edition