problem with sound functionality in ASP.NET and C#
-
I have a problem which i am facing in my chat application. I am working on asp.net 2.0 and C#. My problem is regarding a sound functionality. I have to provide a visitor with a functionality of ringing a bell on the visitor chat window page. So when the visitor rings the bell, it is supposed to ring on the operator's machine. Now i have the below mentioned code... This works fine on a local environment, but when i uploaded this to my server, it doesn't work... the logic is as follows... i have 2 pages - the visitor chat window & the operator chat window... When the visitor presses the bell icon on the visitor chat window page, i write his ID & Is Belled flag onto to an XML file. Now on the operator side i check continuously for correct operator receiving the ringing. Then i am calling the sound function on my server. No plug ins are used... string soundPath = ""; soundPath = "http://"+Request.ServerVariables["HTTP_HOST"]+"/images/LiveChatImages/ringout.wav"; System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer(); myPlayer.SoundLocation = soundPath; myPlayer.Play(); i am using the soundplayer class in asp.net 2.0 another code i also tried with no success is below: public void PlaySound() { string soundPath = ""; soundPath = http://"+Request.ServerVariables["HTTP_HOST"]+"/images/LiveChatImages/ringout.wav"; WSounds ws = new WSounds(); ws.Play(soundPath, ws.SND_FILENAME | ws.SND_ASYNC); } public class WSounds { [DllImport("WinMM.dll")] public static extern bool PlaySound(string fname, int Mod, int flag); // these are the SoundFlags we are using here, check mmsystem.h for more public int SND_ASYNC = 0x0001; // play asynchronously public int SND_FILENAME = 0x00020000; // use file name public int SND_PURGE = 0x0040; // purge non-static events public void Play(string fname, int SoundFlags) { PlaySound(fname, 0, SoundFlags); } } Anybody can help me with my problem... both these codes are working in my local system ... but none work on the server. Can anybody point out where i am wrong? Thanks & regards, S.Dhanasekaran dhansmani@gmail.com :)
-
I have a problem which i am facing in my chat application. I am working on asp.net 2.0 and C#. My problem is regarding a sound functionality. I have to provide a visitor with a functionality of ringing a bell on the visitor chat window page. So when the visitor rings the bell, it is supposed to ring on the operator's machine. Now i have the below mentioned code... This works fine on a local environment, but when i uploaded this to my server, it doesn't work... the logic is as follows... i have 2 pages - the visitor chat window & the operator chat window... When the visitor presses the bell icon on the visitor chat window page, i write his ID & Is Belled flag onto to an XML file. Now on the operator side i check continuously for correct operator receiving the ringing. Then i am calling the sound function on my server. No plug ins are used... string soundPath = ""; soundPath = "http://"+Request.ServerVariables["HTTP_HOST"]+"/images/LiveChatImages/ringout.wav"; System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer(); myPlayer.SoundLocation = soundPath; myPlayer.Play(); i am using the soundplayer class in asp.net 2.0 another code i also tried with no success is below: public void PlaySound() { string soundPath = ""; soundPath = http://"+Request.ServerVariables["HTTP_HOST"]+"/images/LiveChatImages/ringout.wav"; WSounds ws = new WSounds(); ws.Play(soundPath, ws.SND_FILENAME | ws.SND_ASYNC); } public class WSounds { [DllImport("WinMM.dll")] public static extern bool PlaySound(string fname, int Mod, int flag); // these are the SoundFlags we are using here, check mmsystem.h for more public int SND_ASYNC = 0x0001; // play asynchronously public int SND_FILENAME = 0x00020000; // use file name public int SND_PURGE = 0x0040; // purge non-static events public void Play(string fname, int SoundFlags) { PlaySound(fname, 0, SoundFlags); } } Anybody can help me with my problem... both these codes are working in my local system ... but none work on the server. Can anybody point out where i am wrong? Thanks & regards, S.Dhanasekaran dhansmani@gmail.com :)
S.Dhanasekaran wrote:
This works fine on a local environment, but when i uploaded this to my server, it doesn't work...
This is always a sign that you're confusing what happens on the client and on the server.
S.Dhanasekaran wrote:
string soundPath = ""; soundPath = http://"+Request.ServerVariables["HTTP_HOST"]+"/images/LiveChatImages/ringout.wav"; WSounds ws = new WSounds(); ws.Play(soundPath, ws.SND_FILENAME | ws.SND_ASYNC);
If you're doing it on the server, why not use a local path to the file ?
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
S.Dhanasekaran wrote:
This works fine on a local environment, but when i uploaded this to my server, it doesn't work...
This is always a sign that you're confusing what happens on the client and on the server.
S.Dhanasekaran wrote:
string soundPath = ""; soundPath = http://"+Request.ServerVariables["HTTP_HOST"]+"/images/LiveChatImages/ringout.wav"; WSounds ws = new WSounds(); ws.Play(soundPath, ws.SND_FILENAME | ws.SND_ASYNC);
If you're doing it on the server, why not use a local path to the file ?
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
:laugh: (That'll drive the people in the server room bat shit crazy if it has speakers, which could be fun!)
- S 50 cups of coffee and you know it's on!
-
I have a problem which i am facing in my chat application. I am working on asp.net 2.0 and C#. My problem is regarding a sound functionality. I have to provide a visitor with a functionality of ringing a bell on the visitor chat window page. So when the visitor rings the bell, it is supposed to ring on the operator's machine. Now i have the below mentioned code... This works fine on a local environment, but when i uploaded this to my server, it doesn't work... the logic is as follows... i have 2 pages - the visitor chat window & the operator chat window... When the visitor presses the bell icon on the visitor chat window page, i write his ID & Is Belled flag onto to an XML file. Now on the operator side i check continuously for correct operator receiving the ringing. Then i am calling the sound function on my server. No plug ins are used... string soundPath = ""; soundPath = "http://"+Request.ServerVariables["HTTP_HOST"]+"/images/LiveChatImages/ringout.wav"; System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer(); myPlayer.SoundLocation = soundPath; myPlayer.Play(); i am using the soundplayer class in asp.net 2.0 another code i also tried with no success is below: public void PlaySound() { string soundPath = ""; soundPath = http://"+Request.ServerVariables["HTTP_HOST"]+"/images/LiveChatImages/ringout.wav"; WSounds ws = new WSounds(); ws.Play(soundPath, ws.SND_FILENAME | ws.SND_ASYNC); } public class WSounds { [DllImport("WinMM.dll")] public static extern bool PlaySound(string fname, int Mod, int flag); // these are the SoundFlags we are using here, check mmsystem.h for more public int SND_ASYNC = 0x0001; // play asynchronously public int SND_FILENAME = 0x00020000; // use file name public int SND_PURGE = 0x0040; // purge non-static events public void Play(string fname, int SoundFlags) { PlaySound(fname, 0, SoundFlags); } } Anybody can help me with my problem... both these codes are working in my local system ... but none work on the server. Can anybody point out where i am wrong? Thanks & regards, S.Dhanasekaran dhansmani@gmail.com :)
Google <bgsound> for IE and <embed> for FF, etc.
- S 50 cups of coffee and you know it's on!