Solved

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

Posted on 2002-04-11
5
167 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
Comment Utility
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
Comment Utility
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
Comment Utility
The answer to your previous question obviously answered your question, so award the points to Venci75.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
I meant the previous question, not this one :)
0
 

Author Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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 “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now