-2

Possible Duplicate:
how to play a sound in asp.net web page?

hi I'm trying to play a sound by click button .but it doesn't play this sound .it plays another sound ever. I don't want to use absolute address I need to use relative address. this is my code

 protected void Button1_Click1(object sender, EventArgs e)
    {

       System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
       System.IO.Stream s = a.GetManifestResourceStream("chimes.wav");
       SoundPlayer player = new SoundPlayer(s);
       player.Play();       
    }

in this code value of s is always NULL and I don't know why.

Community
  • 1
  • 1
Hadi Nemati
  • 547
  • 3
  • 11
  • 23

1 Answers1

2

You must distinguish between the code that run on server and the code that run on client browser.

The code you have write here is "try" to run on server, and even if its run, the IT manager will start hear "clicks" and not the user.

You can look this answer https://stackoverflow.com/a/12329209/159270 from your previous same question and try to understand the different, the sound must be played on clients browser, not on server.

and also you can read this question answer with more details about: How to play audio and video files in web browser?


(source: planethost.gr)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Aristos
  • 66,005
  • 16
  • 114
  • 150