JAVA程序编写后eclipse检测没问题,运行后播放音乐放不出来……求解…… 10
1个回答
展开全部
<pre t="code" l="java">package test;
import java.applet.AudioClip;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JApplet;
public class YuGiOh
{
public static AudioClip loadSound ( String filename )
{
URL url = null;
try
{
url = new URL ("file:" + filename);
}
catch (MalformedURLException e)
{}
return JApplet.newAudioClip (url);
}
public static void main ( String[] args )
{
AudioClip audioClip = loadSound ("keyboard.wav");
audioClip.play ();
}
}
import java.applet.AudioClip;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JApplet;
public class YuGiOh
{
public static AudioClip loadSound ( String filename )
{
URL url = null;
try
{
url = new URL ("file:" + filename);
}
catch (MalformedURLException e)
{}
return JApplet.newAudioClip (url);
}
public static void main ( String[] args )
{
AudioClip audioClip = loadSound ("keyboard.wav");
audioClip.play ();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询