7 Replies - 22162 Views - Last Post: 08 December 2007 - 12:49 AM Rate Topic: -----

#1 salim2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-May 07

Problem with the c# System.Media.SoundPlayer class on a web host

Posted 09 May 2007 - 07:57 AM

Hi,
I'm doing a web application using asp.net and c# as the code behind.
I wanted to add sound to my web application so I decided to use the System.Media.SoundPlayer class. something like this:

System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
myPlayer.SoundLocation = @"sound.wav";
myPlayer.Play();



Everything works fine when I run the solution on my local computer, but when I upload my site on the web host the sound doesn't play at all. There is not even a error message.
I do not want to use javascrip to make the sound because I need the sound to be related to functions made in the c# code.

If anyone know how I can make this work, help would be very appreciated. Thank you

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with the c# System.Media.SoundPlayer class on a web host

#2 JellyBean  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 60
  • Joined: 25-April 07

Re: Problem with the c# System.Media.SoundPlayer class on a web host

Posted 09 May 2007 - 10:35 AM

Have you tried putting the sound file on a web server and referencing it like this?
http://someserver.com/sound.wav

I'm not certain but I think your web app is looking for the sound.wav file locally. This won't work on a client system since they don't have the file....

This page on MSDN says you can specify a URL for the SoundLocation property. Give it a try!
Was This Post Helpful? 0
  • +
  • -

#3 salim2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-May 07

Re: Problem with the c# System.Media.SoundPlayer class on a web host

Posted 09 May 2007 - 10:45 AM

Thank you Jelly Bean for your reply, but yes I did do that.

Also, when I run the application on my console and use the link to the sound file on the web host, it works fine.
It seems like the sound file plays where ever the c# code is, or something.

This post has been edited by salim2: 09 May 2007 - 10:51 AM

Was This Post Helpful? 0
  • +
  • -

#4 JellyBean  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 60
  • Joined: 25-April 07

Re: Problem with the c# System.Media.SoundPlayer class on a web host

Posted 09 May 2007 - 01:27 PM

After googling around a bit it seems that Flash is the best way to implement a client audio player over the web. I found an article on codeproject.com about how to implement a Flash mp3 player.
http://www.codeproje...ayerControl.asp

This control seems to be flexible. Take a look at it's properties:
Src: URL location of the MP3 file.
Stream: Boolean value to indicate whether MP3 file should be streamed. (Otherwise file is preloaded)
AutoStart: Boolean value to indicate whether file should start when page loads. (Guaranteed to annoy or your money back)
Loop: Boolean value to indicate whether file should play itself again when it ends.
Console: Boolean value to indicate whether to display the UI.

If you do find a pure .NET solution please post back here. :) I'd be really interested to see your solution!
Was This Post Helpful? 0
  • +
  • -

#5 gkarthi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-August 07

Re: Problem with the c# System.Media.SoundPlayer class on a web host

Posted 20 August 2007 - 04:22 AM

Hi im aravinth, Im doing a web application using asp.net and c# code behind.I wanted to add sound file to my web application so I tried with System.Media.SoundPlayer class. the code which u mentioned as

System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
myPlayer.SoundLocation = @"E:\aa.wav";
myPlayer.Play();



when I run the solution on my local computer.There is a error message."Sound API only supports playing PCM wave files."
If u know how I can make this work, pls help me with tis.Thank you
Was This Post Helpful? 0
  • +
  • -

#6 Krirkjung  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-August 07

Re: Problem with the c# System.Media.SoundPlayer class on a web host

Posted 22 August 2007 - 10:24 PM

I suggest you should use flash movie instead Media player control because Media player dose not support stream.
Was This Post Helpful? 0
  • +
  • -

#7 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Problem with the c# System.Media.SoundPlayer class on a web host

Posted 24 August 2007 - 05:07 AM

View Postgkarthi, on 20 Aug, 2007 - 04:22 AM, said:

Hi im aravinth, Im doing a web application using asp.net and c# code behind.I wanted to add sound file to my web application so I tried with System.Media.SoundPlayer class. the code which u mentioned as

System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
myPlayer.SoundLocation = @"E:\aa.wav";
myPlayer.Play();



when I run the solution on my local computer.There is a error message."Sound API only supports playing PCM wave files."
If u know how I can make this work, pls help me with tis.Thank you


gkarthi its not good forum etiquette to ask a question in someone else's thread, just my opinion :)
Was This Post Helpful? 0
  • +
  • -

#8 satomuji  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-December 07

Re: Problem with the c# System.Media.SoundPlayer class on a web host

Posted 08 December 2007 - 12:49 AM

View Postsalim2, on 9 May, 2007 - 10:45 AM, said:

Thank you Jelly Bean for your reply, but yes I did do that.

Also, when I run the application on my console and use the link to the sound file on the web host, it works fine.
It seems like the sound file plays where ever the c# code is, or something.


I'm having the exact same problem. It seems that the sound file plays on the server side rather than on the client side. Sorry, I'm new to .NET development. I think I'm missing something. here...

SoundPlayer MyPlayer = new SoundPlayer();
MyPlayer.SoundLocation =  "http://test/123.wav;		
MyPlayer.Play();



When the page with the above code load on the Mobile browser, the *.wav plays on the server instead of on the Mobile device. I need the *.wav file to play on the Mobile device. Do I need some streaming or anything??? Any suggestions? Btw I'm using Mobile Web Form. Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1