problem with playing audio files

i am at almost out of time to get a jukebox designed and working. I have wrote my application and when i compile it i get the process complete but when itry to execute it i get the following message:

--Configuration: Help - JDK version 1.6.0 <Default> - <Default>--

Exception in thread"main" java.lang.NullPointerException

at sun.applet.AppletAudioClip.<init>(AppletAudioClip.java:48)

at java.applet.Applet.newAudioClip(Applet.java:279)

at Help.<init>(Help.java:60)

at Help.main(Help.java:137)

Process completed.

i will post my code and i will highlight where line 60 isif that helps. i would appreciate the help.

/* @(#)Help.java

*

* Help application

*

* @author

* @version 1.00 2006/12/30

*/

[code]import java.applet.Applet;

import java.applet.AudioClip;

import java.awt.BorderLayout;

import java.awt.Button;

import java.awt.Canvas;

import java.awt.Checkbox;

import java.awt.CheckboxGroup;

import java.awt.Color;

import java.awt.FlowLayout;

import java.awt.Font;

import java.awt.Frame;

import java.awt.Graphics;

import java.awt.List;

import java.awt.Panel;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.net.URL;

publicclass Helpextends Frame{

private Panel controlPanel;

private Panel drawPanel;

private Panel topPanel;

private Panel rPanel;

private CheckboxGroup genre;

private Checkboxrock;

private Checkboxpop;

private Buttonplay;

private Buttonstop;

private Buttonchangegenre;

private List rockChoice, popChoice;

private DrawingCanvas DrawingCanvas;

private Stringpoplist[];

private Stringrocklist[];

private URLurl1;

private URLurl2;

private URLurl3;

private URLurl4;

private URLurl5;

private URLurl6;

private AudioClip[]rockMusic;

private URLurl7;

private URLurl8;

private URLurl9;

private URLurl10;

private URLurl11;

private AudioClip[]popMusic;

private AudioClipcurrent;

public Help()//costructor

{

rockMusic =new AudioClip[6];

rockMusic[0] = Applet.newAudioClip(url1);[b] [u]//this is line 60[/u][/b]

rockMusic[1] = Applet.newAudioClip(url2);

rockMusic[2] = Applet.newAudioClip(url3);

rockMusic[3] = Applet.newAudioClip(url4);

rockMusic[4] = Applet.newAudioClip(url5);

rockMusic[5] = Applet.newAudioClip(url6);

try

{

url7 =new URL("file","localhost","song7.wav");

url8 =new URL("file","localhost","song8.wav");

url9 =new URL("file","localhost","song9.wav");

url10 =new URL("file","localhost","song10.wav");

url11 =new URL("file","localhost","song11.wav");

}

catch (Exception exception){}

popMusic =new AudioClip[5];

popMusic[0] = Applet.newAudioClip(url7);

popMusic[1] = Applet.newAudioClip(url8);

popMusic[2] = Applet.newAudioClip(url9);

popMusic[3] = Applet.newAudioClip(url10);

popMusic[4] = Applet.newAudioClip(url11);

setLayout(new BorderLayout());

drawPanel =new Panel();

drawPanel.setLayout(new BorderLayout());

drawPanel.setBackground(Color.black);

DrawingCanvas drawingCanvas =new DrawingCanvas();

drawPanel.add(drawingCanvas,"Center");

add(drawPanel,"North");

stop =new Button("STOP");

stop.setBackground(Color.blue);

play =new Button("PLAY");

play.setBackground(Color.blue);

changegenre =new Button("CHANGE GENRE");

changegenre.setBackground(Color.blue);

controlPanel =new Panel();

controlPanel.setBackground(Color.red);

controlPanel.setLayout(new FlowLayout());

controlPanel.add(play);

play.addActionListener(new ButtonListener());

controlPanel.add(stop);

stop.addActionListener(new ButtonListener());

controlPanel.add(changegenre);

changegenre.addActionListener(new ButtonListener());

add(controlPanel,"South");

genre =new CheckboxGroup();

rock =new Checkbox("ROCK", genre,false);

pop =new Checkbox("POP", genre,true);

topPanel =new Panel();

topPanel.setLayout(new FlowLayout());

topPanel.setBackground(Color.yellow);

topPanel.add(rock);

topPanel.add(pop);

rocklist =new String[]{

"Select Rock Song","Turn Up The Sun","Mucky Fingers","LYLA","Love Like A Bomb","A Bell Will Ring","Let There BE Love"

};

rockChoice =new List();

for (int i = 0; i < rocklist.length; i++)

rockChoice.add(rocklist[i]);

poplist =new String[]{"Select Pop Song","The Importance Of Being Idle","The Meaning Of Soul","Guess God Thinks I Am Able","Part Of TheQueue","Keep The Dream Alive"};

popChoice =new List();

for (int i = 0; i < poplist.length; i++)

popChoice.add(poplist[i]);

topPanel.add(rockChoice);

rockChoice.setVisible(false);

rockChoice.addActionListener(new ListListener());

topPanel.add(popChoice);

popChoice.setVisible(true);

popChoice.addActionListener(new ListListener());

add(topPanel,"Center");

addWindowListener(new WindowAdapter(){

publicvoid windowClosing(WindowEvent e){

dispose();

System.exit(0);

}

});

}

publicstaticvoid main(String[] args){

Help mainFrame =new Help();

mainFrame.setSize(800, 600);

mainFrame.setTitle("Glenn's Java Jukebox");

mainFrame.setVisible(true);

}

privateclass DrawingCanvasextends Canvas{

private DrawingCanvas(){

setSize(100, 400);

}

publicvoid paint(Graphics g){

// do all the drawing of the jukebox in the

g.drawString("please work", 50, 50);

g.setColor(Color.yellow);

g.fillRect(700, 105, 30, 450);

g.fillRect(80, 105, 30, 450);

g.setColor(Color.yellow);

g.fillArc(80, 10, 650, 200, -180, -180);

g.setColor(Color.white);

g.fillOval(150, 60, 20, 20);

g.fillOval(210, 60, 20, 20);

g.fillOval(270, 60, 20, 20);

g.fillOval(330, 60, 20, 20);

g.fillOval(390, 60, 20, 20);

g.fillOval(630, 60, 20, 20);

g.fillOval(450, 60, 20, 20);

g.fillOval(510, 60, 20, 20);

g.fillOval(570, 60, 20, 20);

g.setColor(Color.black);

g.fillOval(180, 60, 20, 20);

g.fillOval(240, 60, 20, 20);

g.fillOval(300, 60, 20, 20);

g.fillOval(360, 60, 20, 20);

g.fillOval(420, 60, 20, 20);

g.fillOval(480, 60, 20, 20);

g.fillOval(540, 60, 20, 20);

g.fillOval(200, 80, 15, 15);

g.fillOval(380, 80, 15, 15);

g.fillOval(260, 80, 15, 15);

g.fillOval(320, 80, 15, 15);

g.fillOval(380, 80, 15, 15);

g.fillOval(440, 80, 15, 15);

g.fillOval(500, 80, 15, 15);

g.fillOval(560, 80, 15, 15);

g.fillOval(620, 80, 15, 15);

g.fillOval(680, 80, 15, 15);

g.fillOval(140, 80, 15, 15);

g.fillOval(600, 60, 20, 20);

g.fillOval(660, 60, 20, 20);

g.setColor(Color.red);

g.fillOval(110, 80, 15, 15);

g.fillOval(170, 80, 15, 15);

g.fillOval(230, 80, 15, 15);

g.fillOval(290, 80, 15, 15);

g.fillOval(350, 80, 15, 15);

g.fillOval(410, 80, 15, 15);

g.fillOval(470, 80, 15, 15);

g.fillOval(530, 80, 15, 15);

g.fillOval(590, 80, 15, 15);

g.fillOval(650, 80, 15, 15);

g.setColor(Color.white);

g.fillRect(110, 100, 600, 500);

g.setColor(Color.magenta);

g.setFont(new Font("TimesRoman", Font.ITALIC, 48));

g.drawString(" Swurlitzer Jukebox", 230, 160);

g.setColor(Color.black);

g.setFont(new Font("Helvetica", Font.PLAIN, 18));

g.drawString(" 1.50 For 4 Plays", 140, 380);

g.drawString("Please Select Your Genre", 400, 380);

g.setFont(new Font("Helvetica", Font.ITALIC, 18));

g.drawString("Glenn Proudly Presents", 290, 40);

}

}//end DrawingCanvas

privateclass ListListenerimplements ActionListener{

publicvoid actionPerformed(ActionEvent e){

if (current !=null)

current.stop();

Checkbox chk = genre.getSelectedCheckbox();

if ("rock".equals(chk.getLabel()))

current = rockMusic[rockChoice.getSelectedIndex()];

elseif ("pop".equals(chk.getLabel()))

current = popMusic[popChoice.getSelectedIndex()];//213x1

}

}

privateclass ButtonListenerimplements ActionListener{

publicvoid actionPerformed(ActionEvent event){

if (current !=null)

current.stop();

if (event.getSource() == play)

if (current !=null)

current.play();

if (event.getSource() == changegenre)

changeGenre();

}

}//end ButtonListener

privatevoid changeGenre()//line 229

{

Checkbox c = genre.getSelectedCheckbox();

if (c.getLabel() =="rock")//line 232

{

popChoice.setVisible(false);

rockChoice.setVisible(true);//line235

}//236

elseif (c.getLabel() =="pop"){

//etc for other genres..

repaint();

}//end changeGenre() //line 241

}

}

[16707 byte] By [fowlergod09a] at [2007-11-26 13:49:35]
# 1

rockMusic = new AudioClip[6];

try

{

rockMusic[0] = Applet.newAudioClip(new java.net.URL("file:song7.wav"));

rockMusic[1] = Applet.newAudioClip(new java.net.URL("file:song7.wav"));

rockMusic[2] = Applet.newAudioClip(new java.net.URL("file:song7.wav"));

rockMusic[3] = Applet.newAudioClip(new java.net.URL("file:song7.wav"));

rockMusic[4] = Applet.newAudioClip(new java.net.URL("file:song7.wav"));

rockMusic[5] = Applet.newAudioClip(new java.net.URL("file:song7.wav"));

}

catch (Exception exception) {}

popMusic = new AudioClip[5];

try

{

popMusic[0] = Applet.newAudioClip(new java.net.URL("file:song7.wav"));

popMusic[1] = Applet.newAudioClip(new java.net.URL("file:song7.wav"));

popMusic[2] = Applet.newAudioClip(new java.net.URL("file:song7.wav"));

popMusic[3] = Applet.newAudioClip(new java.net.URL("file:song7.wav"));

popMusic[4] = Applet.newAudioClip(new java.net.URL("file:song7.wav"));

}

catch (Exception ex) {}

replace the earlier assigning of songs with this and change the song files.

The URL variables are not needed in this. I am pretty sure it will work.

If that does not work, try changing the files to .au, I only tested using the above method with .au files.

Message was edited by:

Bz_Unknown

Bz_Unknowna at 2007-7-8 1:26:05 > top of Java-index,Java Essentials,New To Java...
# 2

the code now executes but when i try the changegenre button nothing happens, when i try to select and play a track nothing happens. i will try using .au files

can anyone see why the buttons are not working properly?

also i have converted cd tracks to .wav and copied them into the class folder of the app is that correct?

thanks

fowlergod09a at 2007-7-8 1:26:05 > top of Java-index,Java Essentials,New To Java...
# 3

if ("rock".equals(chk.getLabel()))

current = rockMusic[rockChoice.getSelectedIndex()];

else if ("pop".equals(chk.getLabel()))

current = popMusic[popChoice.getSelectedIndex()];

use equalsIgnoreCase, it you look above at ur code, the label is not exactl rock or pop, the capitalization is different. That would not set current to a value.

Bz_Unknowna at 2007-7-8 1:26:05 > top of Java-index,Java Essentials,New To Java...
# 4
I understand what you are saying but can you explain how i use equalsignorecase as i have never used it beforeby the way thxs for helping i really appreciate it
fowlergod09a at 2007-7-8 1:26:05 > top of Java-index,Java Essentials,New To Java...
# 5
instead of .equals() replace with a .equalsIgnoreCase()
Bz_Unknowna at 2007-7-8 1:26:05 > top of Java-index,Java Essentials,New To Java...
# 6
fowlergod09,why are you following up this question on two threads? the another threads is: http://forum.java.sun.com/thread.jspa?threadID=5120157 < http://forum.java.sun.com/thread.jspa?threadID=5120157&tstart=0&start=0>&tstart=0&start=0
AjaySingh516a at 2007-7-8 1:26:05 > top of Java-index,Java Essentials,New To Java...
# 7

Hey fowler, The problem you have here is not audio, its a design error in your code. The sound plays with the way I showed above as an .au file.

There error is here and make sure you change all your .equals to .equalsIgnoreCase

topPanel.add(rockChoice);

rockChoice.setVisible(false); // You are setting it not visible always. Change that line so that it will set Visible only when it is not selected

rockChoice.addActionListener(new ListListener());

topPanel.add(popChoice);

popChoice.setVisible(true);

popChoice.addActionListener(new ListListener());

Bz_Unknowna at 2007-7-8 1:26:05 > top of Java-index,Java Essentials,New To Java...