Author Topic: PHP& MySQL Video Playlist (JW Player)  (Read 2976 times)

ErnieAlex

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 1599
  • Karma: +26/-2
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #30 on: February 03, 2012, 10:28:02 PM »
Ah, I'm confused, or maybe you are.

   You said you wanted to make many "Playlists" which would be made up of various "Videos".
To do this, you must have two tables. One with the videos and all of their details and a second one
that that contains the FINISHED playlists.  We are not at the point of create a "playlist" from the video
table.  That would be later.  Right now we are just trying to get a playlist to work with JW.

   SO, yes, the row stuff you changed would work, but, it pulls videos, not playlists.  Later on when this
gets working, we will create an ADMIN type of program for you to create playlists from the video lists.
Hope that made sense.  The JW front-end does not have to know anything about the individual videos.

   Let me explain it another way...  If you create a front-end JW page to pull videos and THEN build the
playlist from the video tables, it would be a lot of work going on when it loads.  Also, it would be very
hard to have the next playlist "dynamically" be loaded due to all the "building".  All of that formatting and
playlist building should be down before any user visits.  Otherwise, if a lot of people go there at the same
time, there would be a lot of PHP work going on behind the scenes "building" each part of the playlist.
What I was suggesting is to make a simple front-end like the one I sent.  That is ALL it needs.  It will have
one "dynamic" part added later to allow selection of the various playlists.  But, again, these will just be
loaded quickly from a simple query.   The "behind-the-scenes" part would be a page that would allow you
to "build" the playlist from just click on various videos.

   So, the answer is YES, you altered code would work, but, is not good for what you mentioned that you
wanted to do.  I was looking at your code and noticed you are using 5-8, not 5-9 as I am.  Perhaps that
is a problem.  Update to the current version and my old I sent and see what happens.

   Ernie

jj-dr

  • Senior Member
  • ****
  • Posts: 207
  • Karma: +3/-0
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #31 on: February 03, 2012, 10:45:53 PM »
Yeah, I want to make unlimited playlists. I was just stating a different idea as to how to load the fields in the playlist. But we can stay on your plan, if this complicates things.

5-8, not 5-9?
« Last Edit: February 03, 2012, 10:47:24 PM by jj-dr »

jj-dr

  • Senior Member
  • ****
  • Posts: 207
  • Karma: +3/-0
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #32 on: February 03, 2012, 10:52:27 PM »
Oh, I got it, you meant JW Player 5.9.

I updated but still. But is it working on your end?

Can you expand on the addslashes() and stripslashess() thing?
Thanks.
« Last Edit: February 03, 2012, 10:55:47 PM by jj-dr »

ErnieAlex

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 1599
  • Karma: +26/-2
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #33 on: February 03, 2012, 10:56:04 PM »
No, I didn't mean you were wrong.  That is the way you will create the playlist.

The page that "builds" the playlist will have a string, let's say "$playlist" which you will build thru a loop
that creates the string bit by bit.  It will take a video and do something similar to your code.  The end-result
will be the "playlist" that we stored in the database.

Let's to this.  Update to the current 5.9 as it fixes some errors on certain browsers.  Then, test the code.
If it does not show your videos, RIGHT-CLICK on it and VIEW-SOURCE and if you can not figure out the
errors, post it.  This will be a good start.

We will solve this.  It works on my system, so it's just something minor...

jj-dr

  • Senior Member
  • ****
  • Posts: 207
  • Karma: +3/-0
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #34 on: February 03, 2012, 10:58:18 PM »
I already updated, and nothing. I see the playlist is not being opulled from the DB.

PHP Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>testing vid</title>
</
head>



<
script type="text/javascript" src="mediaplayer_5-9/jwplayer.js"></script>

<div id="container">Loading the player...</div>

<script type="text/javascript">
    jwplayer("container").setup({
        flashplayer: "mediaplayer_5-9/player.swf",
                "playlist.position": "right",
        "playlist.size": 360,
        height: 270,
        width: 720 
    });

</script>

<body>
</body>
</html>
« Last Edit: February 03, 2012, 11:03:35 PM by jj-dr »

jj-dr

  • Senior Member
  • ****
  • Posts: 207
  • Karma: +3/-0
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #35 on: February 03, 2012, 11:21:34 PM »
Take a look at my videos_album table, from a different view. Do you spot anything?

ErnieAlex

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 1599
  • Karma: +26/-2
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #36 on: February 03, 2012, 11:24:07 PM »
That's great!  Now we know what is wrong.  Post the HTML page so I can see what you have at this point.  We have made a bunch of changes...

While I look at that, here is some info on the slashes issue...  It might be good when we get up to the storing of the playlists...   http://php.net/manual/en/function.addslashes.php

(And, if you have never been to this site, bookmark it because it has ALL of the references for PHP!!!)

Lastly, I am totally into this project.  I think it will be great when done.  I just wish I could think of something to use it for.  It will be NICE when it all works.  (I have already started some work on the other parts...  LOL )

jj-dr

  • Senior Member
  • ****
  • Posts: 207
  • Karma: +3/-0
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #37 on: February 03, 2012, 11:31:44 PM »
I agree it will be great tool. Well I am using it for the church website. To upload content on the flight. Also, since the JW Player supports LiveStream (livestream.com) a we are going to use it to broadcast live church services.

The cherry on ice cream would be if we can have some sort filter that will convert the most popular video formats to either FLV, h264 or mp4, which are the standard for the JW player. That way, anybody can upload videos without worring about file format... But maybe I am getting to greedy. I'm excited here.

Here's the latest code.

PHP Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">

<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>testing vid</title>
</
head>


<?
php
  
// Set up server connection and open database, ready it for queries...
  
$hostname='localhost';
  
$username "jesus";
  
$password "7paracristo*";
  
$dbname "maranatha";
  
$dbConn mysql_connect$hostname$username$password );
  @
mysql_select_db($dbname);
  
//include('../_includes/connect.php');
  
 
$albumName='';  // Temporary test playlist for testing...
  
  
$query="SELECT * FROM video_albums WHERE albumName='"$albumName ."'";   // Query the database and load the current playlist
  
$result mysql_query  ($query);
  
$row mysql_fetch_row($result);
  
$albumData $row[2];   //  NOTE: this is MY database setup $row{0}= playlist name , $row[1]= playlist data (Full playlist) 
  
   
mysql_close($dbConn);  // close database connection...
  
?>

<script type="text/javascript" src="mediaplayer_5-9/jwplayer.js"></script>

<div id="container">Loading the player...</div>

<script type="text/javascript">
    jwplayer("container").setup({
        flashplayer: "mediaplayer_5-9/player.swf",
        <?php 
	
	
//echo stripslashes($albumData);
	
	
echo 
$albumData
	
	
 
?>
        "playlist.position": "right",
        "playlist.size": 360,
        height: 270,
        width: 720 
    });
</script>

<body>
</body>
</html>
« Last Edit: February 03, 2012, 11:34:29 PM by jj-dr »

jj-dr

  • Senior Member
  • ****
  • Posts: 207
  • Karma: +3/-0
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #38 on: February 03, 2012, 11:39:16 PM »
I have an idea... it just came to me. I can broadcast my desktop to the website... so I can show you my complete set up... Let me know if you want to to this... and just say ready and I will get started and tell you were to go.

ErnieAlex

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 1599
  • Karma: +26/-2
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #39 on: February 04, 2012, 12:30:46 AM »
I am so sorry, I forgot to comment on that site.  You sent it to me before.  I was impressed with it.
Especially, the way the movie picture it starts with.  That was very nice.  It made me feel like I was in a movie
theater with the movies to follow...  I like that effect.

By the way...  Your use of javascript IS dynamic!!!  Dynamic means keeping the page in place while data on it changes.  You have that basically there.  I liked it.  SO, I see when we get your JW player working a bit better, that you will do some nice work.

I looked at your source for the page and it was very nice.  I do not do much Java or CSS.  I know the basic's, but have started learning both more lately.  So, you might get questions from me soon..

I see you have more experience than you let on.  So, I have been explaining too much.  That site is on the left of my screen on both IE and FF.  And, some of it seems a little small on this laptop.  But, it has a GREAT effect when it opens.  I feel like I'm in at a movie.  Very nice effect!

Also, let's see...  You covered a lot...  Let's not do the desktop to website tonight.  Just got back from a party...   Oh, I am looking into the "PLUGIN" options with JW...  It seems with the correct options, you can add in a video converter.  Not sure if this is possible.  It looks like you can add in video codecs which would solve the problem of other formats.  I just haven't had time to look into it.  Might work.

One thing about JW that I do NOT understand is why they don't play standard AVI's or WMV's... ????  Silly!

So, next, I will send you a test page.  It will include the data in your database you sent earlier.  It will just be a NONE database-playlist.  Let's see if it works.  It it does, then, all is well.  If we will know where to head...

Oh, it is 1 AM here in New England, US...   I assume from the website it is not that time there.. LOL...

jj-dr

  • Senior Member
  • ****
  • Posts: 207
  • Karma: +3/-0
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #40 on: February 04, 2012, 12:38:24 AM »
Great... Thanks for the comments on the site. It's really old and I need to update to use CSS layout. I am more of a designer. But I am good looking for stuff around and combining things here or there.

 I've been learning PHP for like a year. But the thing is I can't think like programmer... you know some times I can get easily lost with silly technical stuff.

OK, I am in Philadelphia, so it's 12:37AM now. Let me know if want to do the screen show sometime later. I also need to take a break... I am consumed on this, and feel very drained.

the JW Player used to be called JW FLV player, only for Flash. Now it also includes h264 and mp4, as well as swf and image formats. They have a version for Silverlight, but it doesn't support playlists, which is major drawback.

Well, I am also on the east coast, but I am building a Spanish website.

Have good night, partner. 8)
« Last Edit: February 04, 2012, 12:54:04 AM by jj-dr »

ErnieAlex

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 1599
  • Karma: +26/-2
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #41 on: February 04, 2012, 12:56:13 AM »
Ok, here is the code for a sample of JW.HTML...  To make sure we are on the same page, please change the ? ? ? to the thumbnail location folder name and some JPG picture.  (Doesn't matter of the picture...)   And, let me know if this page works.... 

  If this shows the videos correctly, then next we will change it to use the database version.  Then, see why it is not pulling the correct data from the database.  I am guessing it is a QUOTE issue.

   Anyway, let's start with getting this page to work.  Next, we will replace the playlist with the database version.  Then, we can move on to the creation of the playlists...
Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<script type="text/javascript" src="mediaplayer_5-9/jwplayer.js"></script>

<div id="container">Loading the player...</div>

<script type="text/javascript">
    jwplayer("container").setup({
    flashplayer: "mediaplayer_5-9/player.swf",
playlist: [
            { duration: 32, file: "/Videos/Video1.flv", image: "/Thumbnails???/???.jpg", title: "Testing - Video 1", description: "Test Video1" },
            { duration: 124, file: "/Videos/Video2.flv", image: "/??????/???.jpg", title: "Testing - Video 2", description: "Test Video2" },
            { duration: 542, file: "/Videos/Video3.flv", image: "/???/???.jpg", title: "Testing - Video 3", description: "Video333333333" }
        ],
        "playlist.position": "right",
        "playlist.size": 360,
        height: 270,
        width: 720
    });
</script>

<body>
</body>
</html>

jj-dr

  • Senior Member
  • ****
  • Posts: 207
  • Karma: +3/-0
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #42 on: February 04, 2012, 02:46:43 PM »
Hi, Ernie. The problem has never been with the HTML. I got that working from the first HTML sample you provided. The playlist is fine when using like this. I tested that before over and over and it is fine.

The issue is only when pulling from the database.
« Last Edit: February 04, 2012, 02:57:11 PM by jj-dr »

jj-dr

  • Senior Member
  • ****
  • Posts: 207
  • Karma: +3/-0
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #43 on: February 04, 2012, 03:35:56 PM »
One thing that still intrigues me is the following:  $albumData = $row[2];

If you take a look at my video_albums table one more time:



Note that playlist field is on column 3. Thus I thought that in $albumData = $row[2]; the number 2 represented column 3. But when we say $row, you mean a data row in the database, and not a column number, right?

I would like to see your database set up to see if this is where we have the issue.

Also, I have the variable $albumName set up like this: $albumName = ' '; or equal to blank. Is that OK?
« Last Edit: February 04, 2012, 03:47:03 PM by jj-dr »

jj-dr

  • Senior Member
  • ****
  • Posts: 207
  • Karma: +3/-0
    • View Profile
Re: PHP& MySQL Video Playlist (JW Player)
« Reply #44 on: February 04, 2012, 03:59:39 PM »
Ok, I finally understand the set up of   $albumName ='Test Playlist1';
It's matching the   $albumName value to the database value in the field playlist. These value will be pulled dynamically at a later time.

At least I got that clear now  :)
« Last Edit: February 04, 2012, 04:14:52 PM by jj-dr »