Solved

Programmically set JWPlayer to playa file from database

Posted on 2012-03-31
6
1,256 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

691 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