Answered by:
C# code to play Audio,Video file

Question
-
User-358266636 posted
Hi:
I have a task of playing audio ,Video file using Asp.Net.I wrote the following code to play Audio file,but i got an error " Please be sure a sound file exists at the specified location.". Audio Drive is not installed in my PC.Is the error ocurred due to Audio Drive not installed in my PC?Can any one send me code to play Audio ,Video file using Asp.Net with C#.
My code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Media;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string s="c:\\Beethoven's Symphony No. 9 (Scherzo).wav"; playaudio(s);
}
public void playaudio(string s)
{
SoundPlayer mplayer = new SoundPlayer(); mplayer.SoundLocation = s; mplayer.Play();
}
}
Saturday, August 9, 2008 6:42 PM
Answers
-
User-508406844 posted
just look over this article...If u face any problem let me know
http://msdn.microsoft.com/en-us/library/bb324497(VS.85).aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, August 12, 2008 6:44 AM -
User915387828 posted
Hi suresh_dotnet,
I guess that your file path has something wrong.
You can try to put the sound file on a web server and referencing it like this.
mplayer.SoundLocation="http://someserver.com/sound.wav".
Also, you can try the following metod as decribed at the folloiwng link.
http://www.codeproject.com/KB/custom-controls/MP3PlayerControl.aspx
http://msdn.microsoft.com/en-us/library/system.media.soundplayer_properties.aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, August 14, 2008 12:17 AM
All replies
-
User437720957 posted
Do you really want the server to play sounds?
Saturday, August 9, 2008 9:31 PM -
User-358266636 posted
Hi:
Yes i want to play sounds,video as well
Thanks
Monday, August 11, 2008 9:53 AM -
User-508406844 posted
just look over this article...If u face any problem let me know
http://msdn.microsoft.com/en-us/library/bb324497(VS.85).aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, August 12, 2008 6:44 AM -
User-19205220 posted
http://www.codeproject.com/KB/audio-video/LiquidVideo.aspx
Tuesday, August 12, 2008 6:48 AM -
User437720957 posted
Hi:
Yes i want to play sounds,video as well
Thanks
Yes, but do you really want the web server to play the sounds and videos? Don't you want them to be played in the browser instead?
Tuesday, August 12, 2008 6:20 PM -
User915387828 posted
Hi suresh_dotnet,
I guess that your file path has something wrong.
You can try to put the sound file on a web server and referencing it like this.
mplayer.SoundLocation="http://someserver.com/sound.wav".
Also, you can try the following metod as decribed at the folloiwng link.
http://www.codeproject.com/KB/custom-controls/MP3PlayerControl.aspx
http://msdn.microsoft.com/en-us/library/system.media.soundplayer_properties.aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, August 14, 2008 12:17 AM -
User-1798313744 posted
Hi!
I have some (audio)wav files ,want to play those through asp.net ..c#
that audio files must play at a strech,that buffering process should not happen.
That audio files consists of some speech,that text must display in the site..no audio controls should be shown in the site..
please help me..........
can you provide me the code..
Thursday, September 4, 2008 2:14 AM -
User-1798313744 posted
Hi i am playing an audio file using asp.net,its playing fine in my local PC,But if i host it in the server and try to play through that link,its not playing.
do you know the reason...let me know the solution for this.following is my code.
one more is - if i close the browser in the mid of audio play then also the audio is playing without stopping.
hope i get the code for my solution...
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Media;
using System.ComponentModel;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string sSelectedAudio = "C:\\Documents and Settings\\Desktop\\home.wav";
SoundPlayer objSoundPlayer = new SoundPlayer(sSelectedAudio);
objSoundPlayer.Play();
}
}
thanks in advance
Monday, September 8, 2008 8:06 AM -
User437720957 posted
You can't use the SoundPlayer to play sounds on a web page (it works locally, since it starts the soundplayer locally). You have to use a Media Player (or similar) control on your web page instead.
http://steveorr.net/articles/StreamingMedia.aspx
Monday, September 8, 2008 1:27 PM -
User-1630252454 posted
linkbutton click the vedio file name and display the vedio how to used asp.net with c#
any one replay me this articals
Wednesday, December 30, 2009 6:13 AM -
User991430816 posted
hello every 1
i want to do a simple task using c #. please help me out.
i just want to play a video file just by clicking a button which i have placed on my form. the only thing i want to play a video file in the panel i have described. juast click the button the video starts playing.
plz plz plz help me. do any body have a code which works somrthing like that. plz mail me. i will mw very greatfull to you for this kindness.
my email id is mbaig_88@hotmail.com
Sunday, August 15, 2010 8:07 AM