Re: Opening an audio file in Java
On Fri, 12 May 2006 03:36:16 +0800, Isha wrote
(in article <1147376176.337826.26120@v46g2000cwv.googlegroups.com>):
Hello I'm trying to find some way to develop a web service that plays
music. I was wondering if there was a way in which I could make a Java
piece of code open a music file? I know I can open a text file and read
it's contents by making use of the ByteBuffer, but how about music? Is
it possible to open the music file and stream and play it using the
WIndows Media Player plugin available on browsers for example? I know
I'm a bit confusing here, but if anyone could help and advice me, I'd
be reeaally grateful.
heres something from our company app that plays whilst it is updating.
private static AudioClip audioClip;
try {
setUpPropFile(); // get any properties
if( PlayIntro==true) {
//start by loading sound file
dosoundLoad(
new URL((((//"file:" +
ourProgramDirectory) +"/") + IntroFile)));
}
dosetupsplash();
if( PlayIntro==true) {
dosoundplay();
}
private static void dosoundLoad(final URL file){
audioClip = Applet.newAudioClip(file);
}
private static void dosoundplay(){
try{
Runnable r2 = new Runnable() {
public void run() {
try {
//AudioClip audioClip = Applet.newAudioClip(file);
audioClip.play();
Thread.yield();
Thread.sleep(2 * 1000L); //sleep for n seconds to load file
} catch (Exception e) {
System.out.println(e);
}
}
}
;
SwingUtilities.invokeLater(r2);}
catch (Exception e) {}
}
--
NewsGuy.Com 30Gb $9.95 Carry Forward and On Demand Bandwidth