I created A tictactoe (creategame class) game on my mac, uploaded it to GitHub, downloaded on windows 7. Then this error occurred while running the eclipse project. On researching, I think its a software/driver issue or it's not detecting the sound files, as a beginner, I am completely stumped. Thanks guys for your help.
> Error with playing sound.
java.lang.NullPointerException
at javax.sound.sampled.AudioSystem.getDefaultMixer(Unknown Source)
at javax.sound.sampled.AudioSystem.getLine(Unknown Source)
at TicTacToe.CreateGame.playSound(CreateGame.java:144)
at TicTacToe.CreateGame.actionPerformed(CreateGame.java:194)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
public void playSound() {
// Load sounds
try {
AudioInputStream A = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/A3_04.wav"));
AudioInputStream Bb = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/Bb4_01.wav"));
AudioInputStream C = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/C5_01.wav"));
AudioInputStream D = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/D4_01.wav"));
AudioInputStream E = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/E4_01.wav"));
AudioInputStream F = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/F4_01.wav"));
AudioInputStream G = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/G4_01.wav"));
// IR and IR2 = random number max 7
AudioInputStream[] Sounds = { C, D, E, F, G, A, Bb };
Clip clip = AudioSystem.getClip();
Clip clip2 = AudioSystem.getClip();
clip.open(Sounds[IR]);
clip2.open(Sounds[IR2]);
clip.start();
clip2.start();
} catch (Exception ex) {
System.out.println("Error with playing sound.");
ex.printStackTrace();
}
}
Thank you very much for your help :P