ASP.NET: Embed Music player

MusicPlayer.aspx file:

var oldgridSelectedColor;
function setMouseOverColor(element) {
oldgridSelectedColor = element.style.backgroundColor;
element.style.backgroundColor = ‘#dcdcdc’;
element.style.cursor = ‘hand’;
}
function setMouseOutColor(element) {
element.style.backgroundColor = oldgridSelectedColor;
element.style.textDecoration = ‘none’;
}

 

 

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

<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″
onrowdatabound=”grid_RowDataBound”
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″ />

 

MusicPlayer.aspx.cs:
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)
        {
            getSongName();
        }
    }
    public void getSongName()
    {
        DirectoryInfo di = new DirectoryInfo(“C:/Inetpub/wwwroot/MasudAhmed/Songs/”);
        if (di.Exists == true)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add(“SongName”);
            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
                dt.Rows.Add(dr);
            }
            //grid.Columns[1].HeaderText = “Here are my favourite songs:”;
            grid.DataSource = dt;
            grid.DataBind();
        }
    }
    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();
    }
}
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s