JAVA音频播放错误 15
编译运行错误:Exceptioninthread"main"java.lang.NullPointerExceptionatsun.applet.AppletAudioC...
编译运行错误:Exception in thread "main" java.lang.NullPointerException
at sun.applet.AppletAudioClip.<init>(Unknown Source)
at java.applet.Applet.newAudioClip(Unknown Source)
at MusicPlayer.<init>(MusicPlayer.java:25)
at MusicPlayer.main(MusicPlayer.java:34)
附上源程序:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.applet.*;
import java.io.*;
import java.applet.AudioClip;
public class MusicPlayer extends Applet implements ActionListener
{
JFrame frame=new JFrame("音乐播放器");
JLabel playL,stopL,nextL,lastL,chooseL,loopL,lrcL;//界面上的Jlabel组件
JTextArea ta=new JTextArea();//界面上显示歌词的组件
JComboBox choose; //界面上显示选择歌曲名称的组件
JFileChooser mc=new JFileChooser();
JButton play,stop,next,last,loop,open;//界面上的按钮组件
//歌曲列表中预设三首歌
String[] musicList={"No More.wav","Burning.wav","You Are Beautiful.wav"};
URL music1=getClass().getResource(musicList[0]);//获取歌曲名称资源
URL music2=getClass().getResource(musicList[1]);
URL music3=getClass().getResource(musicList[2]);
25行:::AudioClip sound1=newAudioClip(music1);//将歌曲资源封装为AudioClip对象
AudioClip sound2=newAudioClip(music2);
AudioClip sound3=newAudioClip(music3);
AudioClip chooseClip=sound2;
boolean looping=false; //是否循序播放
public static void main(String[] args)
{
// TODO Auto-generated method stub
34行::::MusicPlayer that=new MusicPlayer();
that.go();
}
public void go()
{
//太多就省略了!
}
}
麻烦各位大神帮忙解决问题啊,悬赏分不多了着急!!!! 展开
at sun.applet.AppletAudioClip.<init>(Unknown Source)
at java.applet.Applet.newAudioClip(Unknown Source)
at MusicPlayer.<init>(MusicPlayer.java:25)
at MusicPlayer.main(MusicPlayer.java:34)
附上源程序:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.applet.*;
import java.io.*;
import java.applet.AudioClip;
public class MusicPlayer extends Applet implements ActionListener
{
JFrame frame=new JFrame("音乐播放器");
JLabel playL,stopL,nextL,lastL,chooseL,loopL,lrcL;//界面上的Jlabel组件
JTextArea ta=new JTextArea();//界面上显示歌词的组件
JComboBox choose; //界面上显示选择歌曲名称的组件
JFileChooser mc=new JFileChooser();
JButton play,stop,next,last,loop,open;//界面上的按钮组件
//歌曲列表中预设三首歌
String[] musicList={"No More.wav","Burning.wav","You Are Beautiful.wav"};
URL music1=getClass().getResource(musicList[0]);//获取歌曲名称资源
URL music2=getClass().getResource(musicList[1]);
URL music3=getClass().getResource(musicList[2]);
25行:::AudioClip sound1=newAudioClip(music1);//将歌曲资源封装为AudioClip对象
AudioClip sound2=newAudioClip(music2);
AudioClip sound3=newAudioClip(music3);
AudioClip chooseClip=sound2;
boolean looping=false; //是否循序播放
public static void main(String[] args)
{
// TODO Auto-generated method stub
34行::::MusicPlayer that=new MusicPlayer();
that.go();
}
public void go()
{
//太多就省略了!
}
}
麻烦各位大神帮忙解决问题啊,悬赏分不多了着急!!!! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |