To Mr, minhpc_bk
-
hii was going thru the www.codeproject.com, posted my queries of how to play a media file in the embedded Windows Media Player...then u helped me by giving this link (link http://www.codeproject.com/script/comments/forums.asp?msg=1053385&forumid=12076&XtraIDs=12076&searchkw="Embedded+media+player+with+dynamic+filename+value"&sd=1%2F1%2F2005&ed=5%2F6%2F2005#xx1053385xx) i embedded the media player and gave the static path also in the URL attribute... but really not getting how to make it dynamic ?? ya,.. u gave one example in that post.. but really sorry... as i m new to VB.NET .. so could not the concept of how to embedd the javascript in VB.NET ??? so can u plz tell me once again how to make the URL dynamic ??? we ve retrieved the file location of the media files from the database in our project... but not sure how to pass this value to the URL of the media player?????..... so that it becomes dynamic... need ur help.. thanks, in advance...
-
hii was going thru the www.codeproject.com, posted my queries of how to play a media file in the embedded Windows Media Player...then u helped me by giving this link (link http://www.codeproject.com/script/comments/forums.asp?msg=1053385&forumid=12076&XtraIDs=12076&searchkw="Embedded+media+player+with+dynamic+filename+value"&sd=1%2F1%2F2005&ed=5%2F6%2F2005#xx1053385xx) i embedded the media player and gave the static path also in the URL attribute... but really not getting how to make it dynamic ?? ya,.. u gave one example in that post.. but really sorry... as i m new to VB.NET .. so could not the concept of how to embedd the javascript in VB.NET ??? so can u plz tell me once again how to make the URL dynamic ??? we ve retrieved the file location of the media files from the database in our project... but not sure how to pass this value to the URL of the media player?????..... so that it becomes dynamic... need ur help.. thanks, in advance...
Hi there, Take a look at the example below which is a simple web page containing a list of media files and a window media plugin, the markup looks something like:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="VBWebApp1.WebForm1"%>
<HTML>
<HEAD>
<title>Media Files</title>
<script language="javascript">
function StartPlayer(filename)
{
//'objWMP' is the id of the media player.
var player = window.document.getElementById("objWMP");
player.FileName = filename;
player.play();
}
</script>
</HEAD>
<body ms_positioning="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="1">
<TR>
<TD><a href="WebForm1.aspx?mediaID=1">Media 1</a></TD>
</TR>
<TR>
<TD><a href="WebForm1.aspx?mediaID=2">Media 2</a></TD>
</TR>
</TABLE>
<br>
<OBJECT id="objWMP" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" VIEWASTEXT>
</OBJECT>
</form>
</body>
</HTML>The sample code in code-behind:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim mediaID As String = Request.QueryString("mediaID")
If ((Not (mediaID Is Nothing)) AndAlso mediaID.Length > 0) ThenDim mediaPath As String = ReadPathFromDB(mediaID) EmitMediaFileName(mediaPath) End If
End Sub
Private Function ReadPathFromDB(ByVal mediaID As String) As String
Dim mediaPath As String'You code here to pull out the path of the selected media file from DB based on its id. 'You may also need to convert it to an absolute virtual path as the path saved 'in DB should be relative. ... ReadPathFromDB = mediaPath
End Function
Private Sub EmitMediaFileName(ByVal mediaPath As String)
Dim script As String
script = "<script language='javascript'>"
script += "var mediaPath = '" & mediaPath & "';"
script += "StartPlayer(mediaPath);"
script += "</script>"Page.RegisterStartupScript("MediaPath", script)
End Sub
Basically, you can put the client side script code in the webpage using the
-
Hi there, Take a look at the example below which is a simple web page containing a list of media files and a window media plugin, the markup looks something like:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="VBWebApp1.WebForm1"%>
<HTML>
<HEAD>
<title>Media Files</title>
<script language="javascript">
function StartPlayer(filename)
{
//'objWMP' is the id of the media player.
var player = window.document.getElementById("objWMP");
player.FileName = filename;
player.play();
}
</script>
</HEAD>
<body ms_positioning="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="1">
<TR>
<TD><a href="WebForm1.aspx?mediaID=1">Media 1</a></TD>
</TR>
<TR>
<TD><a href="WebForm1.aspx?mediaID=2">Media 2</a></TD>
</TR>
</TABLE>
<br>
<OBJECT id="objWMP" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" VIEWASTEXT>
</OBJECT>
</form>
</body>
</HTML>The sample code in code-behind:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim mediaID As String = Request.QueryString("mediaID")
If ((Not (mediaID Is Nothing)) AndAlso mediaID.Length > 0) ThenDim mediaPath As String = ReadPathFromDB(mediaID) EmitMediaFileName(mediaPath) End If
End Sub
Private Function ReadPathFromDB(ByVal mediaID As String) As String
Dim mediaPath As String'You code here to pull out the path of the selected media file from DB based on its id. 'You may also need to convert it to an absolute virtual path as the path saved 'in DB should be relative. ... ReadPathFromDB = mediaPath
End Function
Private Sub EmitMediaFileName(ByVal mediaPath As String)
Dim script As String
script = "<script language='javascript'>"
script += "var mediaPath = '" & mediaPath & "';"
script += "StartPlayer(mediaPath);"
script += "</script>"Page.RegisterStartupScript("MediaPath", script)
End Sub
Basically, you can put the client side script code in the webpage using the
hiiii... really amazing still dunno much abt u except ur id.... first of all.. thanks a lot... ur code helped me in playing media files dynamically... thanks man and.. would like to know more abt u...
-
hiiii... really amazing still dunno much abt u except ur id.... first of all.. thanks a lot... ur code helped me in playing media files dynamically... thanks man and.. would like to know more abt u...