Solved

Programmically set JWPlayer to playa file from database

Posted on 2012-03-31
6
1,246 Views
Last Modified: 2012-06-02
I have jwplayer and I need to to play a video file selected from database. I can only find where you put the file in manually to play such as file: "/output/video.mp4"

I need it to be as follows: and this does not work for some reason:

Dim strAuthor, strTitle, strWidth, strHeight, strDuration, strOriginalFile, strFLVFile, strImageFile, strUploadTime, strViews, strVideoType, strTags As String
    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim strConn As String = "Data Source=MyDataSource"
        Dim MySQL As String = "Select * From Videos Where ID = 56"
        Dim Conn As New SqlConnection(strConn)
        Dim objDR As SqlDataReader
        Dim Cmd As New SqlCommand(MySQL, Conn)
        Conn.Open()
        objDR = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
        While objDR.Read()
            strAuthor = objDR("Author").ToString()
            strTitle = objDR("Title").ToString()
            strWidth = objDR("Width").ToString()
            strHeight = objDR("Height").ToString()
            strDuration = objDR("Duration").ToString()
            strOriginalFile = objDR("OriginalFile").ToString()
            strFLVFile = objDR("FLVFile").ToString()
            strImageFile = objDR("ImageFile").ToString()
            strUploadTime = objDR("UploadTime").ToString()
            strViews = objDR("Views").ToString()
            strVideoType = objDR("VideoType").ToString()
            strTags = objDR("Tags").ToString()
        End While
        Conn.Close()
       
        msgs.Text = "Output/" & strFLVFile.ToString()
        
    End Sub

HTML...

<div id="container">Loading the player ...</div>    
        <script type="text/javascript">
        jwplayer("container").setup({
            flashplayer: "JWPlayer/player.swf",
            height: 350,
            width: 640,
            autostart: true,
            file: filename    <====== need this from sql data reader above "strFLVFileName"
            image: "JWPlayer/preview.jpg"
         
        });    
     </script>

Open in new window

0
Comment
Question by:mlg101
  • 3
6 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 37793101
use a placeholder to inject the player into your aspx page (scroll down to the solution provided):
http://forums.asp.net/t/1736036.aspx/1
0
 
LVL 1

Author Comment

by:mlg101
ID: 37793317
That is fine but I can't see where to put that in the context of what I have: an aspx page with code behind and html
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 37794766
to get the filename from datareader to your aspx page u can set a global variable using the following code:

msgs.Text = "Output/" & strFLVFile.ToString()
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "strFLVFileName", msgs.Text);

Open in new window


this line will render the page with a global variable called strFLVFileName with the requested filename value.
then in your aspx page simply assign this variable to the jwplayer:

jwplayer("container").setup({
            flashplayer: "JWPlayer/player.swf",
            height: 350,
            width: 640,
            autostart: true,
            file: strFLVFileName,
            image: "JWPlayer/preview.jpg"

Open in new window

0
 
LVL 42

Expert Comment

by:sedgwick
ID: 37794771
to verify that the variable was indeed exists and was set to the filename from the datareader u can view the source of the page once it was loaded and look for a variable called strFLVFileName and check its value.
0
 
LVL 19

Expert Comment

by:Amandeep Singh Bhullar
ID: 38039582
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp web application 3 42
Tools for analysis of code 4 48
null, truthy, falsey confusion 25 31
ASP.net Will we ever be able to build mobile apps in it 6 31
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question