나는 Java에서 사운드를 재생하려고 노력해 왔으며 멈추었습니다.AudioClip이 작동하지 않습니다.
public class Audioapp extends JApplet
{
public class Sound{
public AudioClip song;
public URL songPath;
Sound(){
try{
songPath = new URL(getCodeBase(), "leftfordeath.wav");
song = Applet.newAudioClip(songPath);
}
catch (Exception e) {}
}
public void playSoundOnce(){
song.play();
}
}
public void init(){
Sound test = new Sound();
test.playSoundOnce();
}
}
내 메인에서 init을 호출하면 song.play()에 nullPointerExeption이 있다고 표시됩니다. 내가 뭘 잘못하고 있니, 제발 도와주세요 ...
정말 JApplet을 사용해야합니까? 당신의 주된 방법으로 그것을 부른 이후로 당신이하지 말 것을 제안 할 것입니다. 또한 예외를 무시하지 말고 try-catch 블록의 catch 부분에 e.printStackTrace()를 추가하고 그 내용을 확인하십시오 ... – MadProgrammer