Play Background music on your website using asp.net

This is a simple example to play audio file.

Step 1:

Add an html page and an audio file in your application.

HTML page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>Untitled Page</title>

</head>

    <body>

        <bgsound src="Songs/07 - Hai Dard - Udit Narayan.mp3" loop="0" balance="0" volume="0">

    </body>

</html>

Step 2:

Now add new page as Video.aspx in your application and drop a button control on the page.

Video.aspx:

<form id="form1" runat="server">

    <asp:Button ID="ButtonPlay" runat="server" Text="Play" OnClick="ButtonPlay_Click"/>

</form>

protected void ButtonPlay_Click(object sender, EventArgs e)

{

    Response.Redirect("HTMLPage.htm");

}