Solved

Programmically set JWPlayer to playa file from database

Posted on 2012-03-31
6
1,214 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now