Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. To Mr, minhpc_bk

To Mr, minhpc_bk

Scheduled Pinned Locked Moved ASP.NET
tutorialcsharpjavascriptdatabase
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vishalmishra
    wrote on last edited by
    #1

    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...

    M 1 Reply Last reply
    0
    • V vishalmishra

      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...

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      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) Then

          Dim 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

      V 1 Reply Last reply
      0
      • M minhpc_bk

        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) Then

            Dim 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

        V Offline
        V Offline
        vishalmishra
        wrote on last edited by
        #3

        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...

        M 1 Reply Last reply
        0
        • V vishalmishra

          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...

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          Hi there, I'm glad to hear that my post is helpful to you, I'm simply a crazy CPian, and a fan of Manchester United.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups