mp3不能播放,在线等。。。。。。。。。
程序如下:
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.applet.AudioClip;
public class PlayMedia extends Applet
{
Image testImage;
AudioClip audio;
public void init ()
{
Button btnPlay = new Button ("Play");
Button btnStop = new Button ("Stop");
add (btnPlay);
add (btnStop);
try
{
testImage = getImage (getDocumentBase (), "my.gif");
audio = getAudioClip (getDocumentBase (), "my.mp3");
}
catch (Exception e)
{
System.out.println (e.toString ());
}
btnPlay.addActionListener(new ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
try
{
audio.play ();
}
catch (Exception err)
{
System.out.println (err.toString ());
}
}
});
btnStop.addActionListener (new ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
try
{
audio.stop ();
}
catch (Exception err)
{
System.out.println (err.toString ());
}
finally
{
}
}
});
} //init() ends
public void paint (Graphics g)
{
g.drawImage (testImage, 20, 20, this);
}
/*
public boolean mouseDown (Event evt, int x, int y)
{
audio.play ();
System.out.println("dddd");
return true;
}
*/
}//class ends
现在图片可以显示,
但是,点击play按钮时mp3文件不能播放,怎么回事啊?