Hi all
Can anyone help me with this issue. I am trying to build a webpage which lists a number of mp3 files with a button for each file in the list. When you press the button,I want the relevant mp3 to be played on the embedded media player on the page.
I have attached the code below which shows this for an example. Question is, when the button is pressed, how do I pass the name of the mp3 file to the embedded media player?
Thanks for any pointers.
Flash
EXAMPLE:
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<html>
<script language="VB" runat="server">
Sub Page_load(Sender As Object, E As EventArgs)
dim ds as dataset = new dataset("mydataset")
dim dtable as datatable = ds.tables.add("Music")
Dim dCola As DataColumn = dtable.Columns.Add("Ref", Type.GetType("System.Int32"))
Dim dColb As DataColumn = dtable.Columns.Add("Artist", Type.GetType("System.String"))
Dim dColc As DataColumn = dtable.Columns.Add("Track", Type.GetType("System.String"))
dim dr as datarow = dtable.newrow()
dr(0)=1
dr(1)="DJ Tiesto"
dr(2)="Urban Train"
dtable.rows.add(dr)
DataGrid1.DataSource = ds.Tables("music").DefaultView
DataBind()
end sub
sub Datagrid1_ItemCommand(obj as object, e as _
DataGridCommandEventArgs)
DataGrid1.SelectedIndex = e.Item.ItemIndex
DataBind()
end sub
</script>
<body>
<form runat="server">
<aspataGrid id="DataGrid1" runat="server"
BorderColor="black"
GridLines="Vertical"
cellpadding="4"
cellspacing="0"
width="450"
Font-NameFont-Names="Arial"
Font-Size="8pt"
ShowFooter="True"
HeaderStyle-BackColor="#cccc99"
FooterStyle-BackColor="#cccc99"
ItemStyle-BackColor="#ffffff"
AlternatingItemStyle-Backcolor="#cccccc"
AutoGenerateColumns="false"
OnItemCommand="DataGrid1_ItemCommand">
<Columns>
<asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<asp:Label id="Name" runat="server"
Text='<%# Container.DataItem("Artist")& _
" " & Container.DataItem("Track") %>'/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="Ref"
DataField="Ref"/>
<asp:BoundColumn HeaderText="Artist" DataField="Artist"/>
<asp:BoundColumn HeaderText="Track"
DataField="Track" />
<asp:ButtonColumn HeaderText="Play?" text="Play"
CommandName="item"
ButtonType="PushButton"/>
</Columns>
</aspataGrid>
</form>
<OBJECT
ID="mediaPlayer"
CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
CODEBASE="http://activex.microsoft.com/activex/
controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
STANDBY="Loading Microsoft Windows Media Player components..."
TYPE="application/x-oleobject">
<PARAM NAME="fileName" VALUE="">
<PARAM NAME="animationatStart" VALUE="true">
<PARAM NAME="transparentatStart" VALUE="true">
<PARAM NAME="autoStart" VALUE="false">
<PARAM NAME="showControls" VALUE="true">
</OBJECT>
</body>
</html>
Can anyone help me with this issue. I am trying to build a webpage which lists a number of mp3 files with a button for each file in the list. When you press the button,I want the relevant mp3 to be played on the embedded media player on the page.
I have attached the code below which shows this for an example. Question is, when the button is pressed, how do I pass the name of the mp3 file to the embedded media player?
Thanks for any pointers.
Flash
EXAMPLE:
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<html>
<script language="VB" runat="server">
Sub Page_load(Sender As Object, E As EventArgs)
dim ds as dataset = new dataset("mydataset")
dim dtable as datatable = ds.tables.add("Music")
Dim dCola As DataColumn = dtable.Columns.Add("Ref", Type.GetType("System.Int32"))
Dim dColb As DataColumn = dtable.Columns.Add("Artist", Type.GetType("System.String"))
Dim dColc As DataColumn = dtable.Columns.Add("Track", Type.GetType("System.String"))
dim dr as datarow = dtable.newrow()
dr(0)=1
dr(1)="DJ Tiesto"
dr(2)="Urban Train"
dtable.rows.add(dr)
DataGrid1.DataSource = ds.Tables("music").DefaultView
DataBind()
end sub
sub Datagrid1_ItemCommand(obj as object, e as _
DataGridCommandEventArgs)
DataGrid1.SelectedIndex = e.Item.ItemIndex
DataBind()
end sub
</script>
<body>
<form runat="server">
<aspataGrid id="DataGrid1" runat="server"
BorderColor="black"
GridLines="Vertical"
cellpadding="4"
cellspacing="0"
width="450"
Font-NameFont-Names="Arial"
Font-Size="8pt"
ShowFooter="True"
HeaderStyle-BackColor="#cccc99"
FooterStyle-BackColor="#cccc99"
ItemStyle-BackColor="#ffffff"
AlternatingItemStyle-Backcolor="#cccccc"
AutoGenerateColumns="false"
OnItemCommand="DataGrid1_ItemCommand">
<Columns>
<asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<asp:Label id="Name" runat="server"
Text='<%# Container.DataItem("Artist")& _
" " & Container.DataItem("Track") %>'/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="Ref"
DataField="Ref"/>
<asp:BoundColumn HeaderText="Artist" DataField="Artist"/>
<asp:BoundColumn HeaderText="Track"
DataField="Track" />
<asp:ButtonColumn HeaderText="Play?" text="Play"
CommandName="item"
ButtonType="PushButton"/>
</Columns>
</aspataGrid>
</form>
<OBJECT
ID="mediaPlayer"
CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
CODEBASE="http://activex.microsoft.com/activex/
controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
STANDBY="Loading Microsoft Windows Media Player components..."
TYPE="application/x-oleobject">
<PARAM NAME="fileName" VALUE="">
<PARAM NAME="animationatStart" VALUE="true">
<PARAM NAME="transparentatStart" VALUE="true">
<PARAM NAME="autoStart" VALUE="false">
<PARAM NAME="showControls" VALUE="true">
</OBJECT>
</body>
</html>