suresh s

suresh s

  • NA
  • 37
  • 175.6k

C# code to play Audio,Video File

Aug 9 2008 6:47 PM

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();

 }

 }


Answers (1)