Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Java Sound Problems............

Posted on 2002-04-11
5
Medium Priority
?
189 Views
Last Modified: 2011-09-20
As far as i can see this code is correct but the sound is not being played when the button is pressed!

here is all the code involved

public void mousePressed(MouseEvent event)
{
Object source = event.getSource();
if (source == cotbuttons[0])
{
earlyactivitiescount++;
cotbuttons[0].removeMouseListener(this);
WellDoneSound();
}
}

public void WellDoneSound()
{
try
{
URL welldoneurl = new URL("file://C:/Java/FYP/sounds/welcome.wav");
AudioClip welldoneclip = JApplet.newAudioClip(welldoneurl);
welldoneclip.play();
}
catch (MalformedURLException e){}
}


please help if you can!!!!!!!!!

thank you
 
 


0
Comment
Question by:Codster
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
Venci75 earned 20 total points
ID: 6933789
It is OK, but probably the code inside the if(source == cotbuttons[0]) is not executed.

PS:
What about the
http://www.experts-exchange.com/java/Q.20287396.html
0
 

Author Comment

by:Codster
ID: 6933929
the code is being executed all right have System.out.println("xxxx"); statements everywhere
the import java.net.URL; statement is ok as well
everything seems to be executing only the sound is not being played.

Why do  i not need import javax.sound etc etc?
the file type i am using is a .wav
is there anything involved in that that i have omitted?
0
 
LVL 92

Expert Comment

by:objects
ID: 6935363
The answer to your previous question obviously answered your question, so award the points to Venci75.
0
 
LVL 92

Expert Comment

by:objects
ID: 6935397
I meant the previous question, not this one :)
0
 

Author Comment

by:Codster
ID: 6935401
Thank you
i will award him the points
can you help me with my problem at all?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question