Solved

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

Posted on 2002-04-11
5
168 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 10 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 77
servlet doXXX methods 3 49
MySqlDump not dumping triggers 1 31
Which non-HTML GUI front end to use with Java? 3 22
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

809 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