ASP.NET: Embed Music player

MusicPlayer.aspx file:

var oldgridSelectedColor;
function setMouseOverColor(element) {
oldgridSelectedColor =; = ‘#dcdcdc’; = ‘hand’;
function setMouseOutColor(element) { = oldgridSelectedColor; = ‘none’;



                <asp:UpdatePanel ID=”UpdatePanel1″ runat=”server”
UpdateMode=”Conditional” ChildrenAsTriggers=”False”><asp:AsyncPostBackTrigger

<param name=”url” value= “” />
<param name=”src” value=”” />

<object type=”video/x-ms-wmv” data=”” class=”musicplayer-media”>
<param name=”src” value=”” />


                <asp:GridView ID=”grid” runat=”server” BackColor=”#CC9900″ ForeColor=”#663300″
onselectedindexchanged=”grid_SelectedIndexChanged” DataKeyNames=”songname”>


Media Player Volume Control in – ASP.NET using C#:
The code  should set the media player volume to Full but it does not. Then I tried to put the value=”0″ and it actually works.

  • So correct code is: <param name=”volume” value=”0″ />


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;
using System.Text;
public partial class MusicPlayer : System.Web.UI.Page
    public string mySrc;
    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
    public void getSongName()
        DirectoryInfo di = new DirectoryInfo(“C:/Inetpub/wwwroot/MasudAhmed/Songs/”);
        if (di.Exists == true)
            DataTable dt = new DataTable();
            foreach (FileInfo fi in di.GetFiles(“*.mp3”, SearchOption.AllDirectories))//get filename from this directory
                DataRow dr = dt.NewRow();
                dr[“SongName”] = fi.Name;//show only song name excluding path
            //grid.Columns[1].HeaderText = “Here are my favourite songs:”;
            grid.DataSource = dt;
    protected void grid_RowDataBound(object sender, GridViewRowEventArgs e)
        e.Row.Attributes[“onmouseover”] = “javascript:setMouseOverColor(this);”;
        e.Row.Attributes[“onmouseout”] = “javascript:setMouseOutColor(this);”;
    protected void grid_SelectedIndexChanged(object sender, EventArgs e)
        DirectoryInfo di = new DirectoryInfo(“C:/Inetpub/wwwroot/MasudAhmed/Songs/”);
        mySrc = di + grid.SelectedDataKey.Values[“songname”].ToString();

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s