Link to home
Start Free TrialLog in
Avatar of Rosewell
Rosewell

asked on

How to play a music in Java?

Hello;

I have a problem about playing a music in my java application w/c is in a JFrame, can anyone help me play and add some more functionality on my application, thanks and Good luck guys !.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Try:

File file = new File("bark.wav");
AudioClip clip = Applet.newAudioClip(file.toURL());
clip.play();
ASKER CERTIFIED SOLUTION
Avatar of Javatm
Javatm
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>clip1 = Applet.newAudioClip(url1);

Essentially the same code as i've already posted.
!? Please explain Rosewell...
Avatar of Rosewell
Rosewell

ASKER

Thanks CEHJ;

but you know what I'm asking is more functionality, so may be your code is right but you know I'm not that good in Java programming that's why I choose Javatm's Answer, thanks again . . .
Fair enough then!
and also he provided me a stop and play action for a music file that's why I choose his answer.