Welcome to Dream.In.Code
Become an Expert!

Join 149,478 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,561 people online right now. Registration is fast and FREE... Join Now!




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

 
Reply to this topicStart new topic

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

salim2
9 May, 2007 - 06:57 AM
Post #1

New D.I.C Head
*

Joined: 5 May, 2007
Posts: 4


My Contributions
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:

CODE

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
User is offlineProfile CardPM
+Quote Post

JellyBean
RE: Problem With The C# System.Media.SoundPlayer Class On A Web Host
9 May, 2007 - 09:35 AM
Post #2

D.I.C Head
**

Joined: 25 Apr, 2007
Posts: 60


My Contributions
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!
User is offlineProfile CardPM
+Quote Post

salim2
RE: Problem With The C# System.Media.SoundPlayer Class On A Web Host
9 May, 2007 - 09:45 AM
Post #3

New D.I.C Head
*

Joined: 5 May, 2007
Posts: 4


My Contributions
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: 9 May, 2007 - 09:51 AM
User is offlineProfile CardPM
+Quote Post

JellyBean
RE: Problem With The C# System.Media.SoundPlayer Class On A Web Host
9 May, 2007 - 12:27 PM
Post #4

D.I.C Head
**

Joined: 25 Apr, 2007
Posts: 60


My Contributions
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.codeproject.com/aspnet/MP3PlayerControl.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. smile.gif I'd be really interested to see your solution!
User is offlineProfile CardPM
+Quote Post

gkarthi
RE: Problem With The C# System.Media.SoundPlayer Class On A Web Host
20 Aug, 2007 - 03:22 AM
Post #5

New D.I.C Head
*

Joined: 20 Aug, 2007
Posts: 2


My Contributions

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

CODE

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



User is offlineProfile CardPM
+Quote Post

Krirkjung
RE: Problem With The C# System.Media.SoundPlayer Class On A Web Host
22 Aug, 2007 - 09:24 PM
Post #6

New D.I.C Head
*

Joined: 22 Aug, 2007
Posts: 3


My Contributions
I suggest you should use flash movie instead Media player control because Media player dose not support stream.
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Problem With The C# System.Media.SoundPlayer Class On A Web Host
24 Aug, 2007 - 04:07 AM
Post #7

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,480



Thanked: 161 times
Dream Kudos: 9050
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
QUOTE(gkarthi @ 20 Aug, 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

CODE

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 smile.gif

User is online!Profile CardPM
+Quote Post

satomuji
RE: Problem With The C# System.Media.SoundPlayer Class On A Web Host
7 Dec, 2007 - 11:49 PM
Post #8

New D.I.C Head
*

Joined: 7 Dec, 2007
Posts: 1


My Contributions
QUOTE(salim2 @ 9 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.


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...

CODE

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.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 03:50PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month