URL ur=new URL("file:\\C:\\Demo\\abc.wav"); AudioClip clip =Applet.newAudioClip(ur); It's working fine In fact i have tried getAudioClip() to run "http://Music/demo/abc.wav" but it's not working.
Actually i want to play "http://" URL file directly in applet Please help me.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35223
7
posted
0
Welcome to JavaRanch.
On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.
As to your question, what does "it doesn't work" mean? Are there any exceptions? Does the browser download the file if you enter "http://Music/demo/abc.wav" in the URL field?
Thank you for response.Yes,the browser is downloading the file. The code i'am using is given below: ------------------------------------ package Sound;
public class Sound2{ public static void main(String a[]) { try { String str1="http://simplythebest.net/sounds/WAV" + "/WAV_files/cartoon_WAV_files/aladdin_goodbye.wav";
String str2="file:\\C:\\Documents and Settings\\btripathi" + "\\Desktop\\ChatRoom_15April_Backup\\client\\sound\\ringin.wav";
} } --------------------------------------------- Now when i pass str1 (as shown in //1) it,s workin fine,But whenever i pass str2 or whole URL("http://....").I'am unable to hear any sound.Even i'm not getting a single error. [ July 05, 2007: Message edited by: yoshino ]
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35223
7
posted
0
It's a bit unclear what is now working, and what isn't.
As I understand it, this works:
but this doesn't
and neither does this
Is that correct? That the second one wouldn't work is very strange - it's the same as the first one.
Also, your display name still doesn't conform to the policy. It must consist of a first name and a last name, and not be obviously fictitious. Please take a moment to change it, which you can do right here.
Bagesh Tripathi
Greenhorn
Joined: Jul 04, 2007
Posts: 6
posted
0
Sorry for creating confusion Actually
URL url=new URL("http://simplythebest.net/sounds/WAV/WAV_files/cartoon_WAV_files/aladdin_goodbye.wav"); is NOT working & ------------------------ URL url=new URL("file:\\C:\\Documents and Settings\\btripathi\\Desktop\\ChatRoom_15April_Backup\\client\\sound\\ringin.wav"); is working FINE --------------------------
That is while accessing sound file from local system it's working fine,but while accessing file in Network/Internet it's not working. [ July 05, 2007: Message edited by: Bagesh ]
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35223
7
posted
0
The problem is that the application quits before the clip is loaded. Both the newAudiopClip and play methods return immediately, even if the the clip isn't loaded. If you insert a "Thread.sleep(10000)" after the call to play, you should hear the clip playing.
Also, thanks for changing your display name. Unfortunately, it's still not valid, because -as I said above- it needs to have a first name and a last name. Please fix it accordingly. [ July 05, 2007: Message edited by: Ulf Dittmer ]
Bagesh Tripathi
Greenhorn
Joined: Jul 04, 2007
Posts: 6
posted
0
Hi,
Thank you for your response. i'm using "Thread.sleep(10000)".But still I'm not getting the desired result(no sound ) Given below is the code.Please help me where i'm going wrong
You need to put the call to Thread.sleep after the call to clip.play.
Bagesh Tripathi
Greenhorn
Joined: Jul 04, 2007
Posts: 6
posted
0
Hi, Done this also (i.e putting Thread.sleep after the call to clip.play) no success.If possible please provide some excerpts\source code.It would be great help to me.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35223
7
posted
0
This works for me:
Bagesh Tripathi
Greenhorn
Joined: Jul 04, 2007
Posts: 6
posted
0
Hi,
First of all Thanks a lot for your information & the solution you provided. Given below is my code snipplet: ------------------------------- import java.net.*; import java.applet.*;
public class Sound2 { public static void main(String a[]) throws java.net.MalformedURLException, InterruptedException { URL url = new URL("http://simplythebest.net/sounds/WAV/WAV_files/cartoon_WAV_files/aladdin_goodbye.wav"); AudioClip clip = Applet.newAudioClip(url); clip.play(); Thread.sleep(10000); } } -------------------------------------------
I don't know whats going wrong but i'm still not able to hear the sound.