My friend asked me to create an app that he can use in conjunction with the game Plague Inc, and he wants the soundtrack from the game to play in the application. Upon doing web research I have tried everything and nothing works. Is it possible to call the soundtrack from a java package (like with an image) instead of specifying folder directories and URLs? There was some promising information I found online but when I ran the code after trying it, the AudioInputStream
keeps on giving me errors. I have tried using the clauses exceptions but that severely conflicted with the main method and the application would not even run. I have tried putting the coding in the constructor, a new method and even in the main method itself but all of them just throw out errors when I run the application (I don't even know where to put it so that it will work). Please help as this is getting seriously frustrating.
My package is called Sound and the file is called plague.wav And although the game is an Android game, my application runs off Windows PC
Here is the coding I have so far:
File sound = new File("/Sound/plague.wav");
AudioInputStream audioIn = AudioSystem.getAudioInputStream(sound);
Clip clip = AudioSystem.getClip();
clip.open(audioIn);
clip.loop(Clip.LOOP_CONTINUOUSLY);
} catch (LineUnavailableException ex) {
Logger.getLogger(knownDiseases.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(knownDiseases.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedAudioFileException ex) {
Logger.getLogger(knownDiseases.class.getName()).log(Level.SEVERE, null, ex);
}