• Post Reply Bookmark Topic Watch Topic
  • New Topic

Playing a simple .wav file in the application?  RSS feed

 
Ivor Horton Evil
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is simple
I want to play a simple .WAV file in my application (IN FRAME) (NOT IN AN APPLET)...
Kindly send me a sample code or some guidelines.
Thanking you.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to send this to the 'Other APIs' forum. It is not directly an IO question.
Dave
 
Lewin Chan
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://java.sun.com/docs/books/tutorial/sound/playing.html
has a section in there about playing sounds in an application.

In JDK 1.2, applications as well as applets can play sounds. A new static method has been added to java.applet.Applet to enable applications to create AudioClips from a URL.
public static final AudioClip newAudioClip(URL r)
To play a sound from an applet, you call Applet.newAudioClip to load the sound and then use the AudioClip play, loop, and stop methods to control playback. For example, to play a WAV file from an application, you could
1. Call Applet.newAudioClip and pass in the URL where the .wav file is located.
2. Call play or loop on the AudioClip.

Ah, the wonders of sun's example code
L
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!