using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 WMPLib; //Add this COM Component Reference to your project
public partial class PlayMusic : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnPlayMusic_Click(object sender, EventArgs e)
{
string _path = "File Path";
//Method 1 using sound player class
SoundPlayer _sm = new SoundPlayer(_path);
_sm.Play();
//Method 2
Microsoft.VisualBasic.Devices.Audio _mvda = new Microsoft.VisualBasic.Devices.Audio();
_mvda.Play(_path, Microsoft.VisualBasic.AudioPlayMode.Background);
//Method 3 using WindowsMediaPlayer Class
WindowsMediaPlayerClass _wmpc = new WindowsMediaPlayerClass();
_wmpc.openPlayer(_path);
_wmpc.play();
}
}
No comments:
Post a Comment