Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. problem with sound functionality in ASP.NET and C#

problem with sound functionality in ASP.NET and C#

Scheduled Pinned Locked Moved ASP.NET
csharphelpasp-netcomsysadmin
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    S Dhanasekaran
    wrote on last edited by
    #1

    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 :)

    C Steve EcholsS 2 Replies Last reply
    0
    • S S Dhanasekaran

      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 :)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      Steve EcholsS 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        Steve EcholsS Offline
        Steve EcholsS Offline
        Steve Echols
        wrote on last edited by
        #3

        :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!

        • S
          50 cups of coffee and you know it's on!
          Code, follow, or get out of the way.
        1 Reply Last reply
        0
        • S S Dhanasekaran

          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 :)

          Steve EcholsS Offline
          Steve EcholsS Offline
          Steve Echols
          wrote on last edited by
          #4

          Google <bgsound> for IE and <embed> for FF, etc.


          - S 50 cups of coffee and you know it's on!

          • S
            50 cups of coffee and you know it's on!
            Code, follow, or get out of the way.
          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups