PHP& MySQL Video Playlist (JW Player)

Wow! Very nice post. It gave me a nice overview of your code and database set up. Nice!

Okay, simple error. Your Video_Albums table should have another field called “Playlist”. In that field, you should be storing the actual playlist that looks something like this:

  playlist: [
        { duration: 32, file: "/Videos/Video1.flv", image: "/Thumbnails/Thumbnail1.jpg", title: "Testing - Video 1", description: "Description of video 1.  Well, I have nothing... LOL" },
        { duration: 124, file: "/Videos/Video2.flv", image: "/Thumbnails/Thumbnail2.jpg", title: "Testing - Video 2", description: "Blah, Blah, Blah..." },
        { duration: 542, file: "/Videos/Video3.flv", image: "/Thumbnails/Thumbnail3.jpg", title: "Testing - Video 3", description: "Dum Dum De Dum..  Drum roll...  Another drum roll..  Well?  Did it work???" }
         ],

Of course, this would be your playlist for the two videos you have. In the next section which is almost ready to send to you, this part will be replaced with the “dynamic” part.

So, create a playlist similar to above, changing the names and text. Then, store this inside your Video_Albums’ new field called something like “Playlist”. Then, change “albumData=$row[?]” to point to the new field. Then you should get videos…

Let me know how it worked…

OK, I am on it… I will get back to you as soon as I am done.

OK, I entered the data but I am not sure if I did it right. Here’s its…

And again, result is the same: blank player.

You entered a playlist into the database. Did you change the query to point at it?
This is what you showed in the previous post:

$albumName=“Test Playlist1”; // Temporary test playlist for testing…
$query=“SELECT * FROM video_albums WHERE albumName=’”. $albumName ."’"; // Query the database and load the current playlist

This will not work. You named the new playlist “First Album”, so change it from “Test Playlist1” to “First Album”.

I am leaving for awhile soon…

OK, I’ll play with it.

OK, still not working. Let’s review…
1) My latest code:
[php]<?php
// Set up server connection and open database, ready it for queries…
$hostname=‘localhost’;
$username = “jj-dr”;
$password = “pass”;
$dbname = “videosdb”;
$dbConn = mysql_connect( $hostname, $username, $password );
@mysql_select_db($dbname);
//include(’…/_includes/connect.php’);

$albumName=“Test Playlist1”; // 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[1]; // NOTE: this is MY database setup $row{0}= playlist name , $row[1]= playlist data (Full playlist)
mysql_close($dbConn); // close database connection…

?>

Loading the player...

[/php]

Note that I am keeping $albumName=“Test Playlist1” but I am confused as to why we have the name if it’s supposed to come from the DB.

2) My DB Setup:

3) Stored playlist inside playlist field in video_albums table:

[code]playlist: [
{ duration: 32, file: “VIDEOS/Video01.flv”, image: “thumbS/preview.jpg”, title: “Testing - Video 1”, description: "Description of video 1.

Well, I have nothing… LOL" },
{ duration: 124, file: “VIDEOS/Video02.flv”, image: “thumbs/preview.jpg”, title: “Testing - Video 2”, description: “Blah, Blah, Blah…”

},
{ duration: 542, file: “VIDEOS/Video03.flv”, image: “thumbs/preview.jpg”, title: “Testing - Video 3”, description: "Dum Dum De Dum… Drum

roll… Another drum roll… Well? Did it work???" }

<–

    ],[/code]

What am I missing?

Also, XML playlists contain header data, should that be included as well? I mean:

<?xml version="1.0" encoding="UTF-8"?>

Finally, now I the player will not load, and I just get the div message Loading The Player…
Is this line OK?: $albumData = $row[1];
If I change to $albumData = $row['playlist’]; , the player loads but I get this message

Notice: Undefined index: playlist in F:\wamp\www\PHPVIDEOS\videos.php on line 24

LOL, been gone, just got back and this JUMPED out at me…

$albumData = $row[1];

$row[0] is album ID
$row[1] is album name
$row[2] is album data…

CHANGE it to $row[2]; Let me know it that works…

Oh, also, I have had trouble with the quotes and double-quotes storing into MySQL.
It seems you have to store them with addlashes(…) and read them back with stripslashes()…
This turns quotes " into slash-quotes "… I noticed you did not have slashes in your database version of the playlist. So, for this test, you may have to remove the stripslashes from the code.

*** Here is a trick I use ALL the time. Once you change the playlist number above, see what is display on your webpage. Right-Click on a blank area on the page and select View-Source. This will open a new window with the “RENDERED” source of what results from the combined HTML and PHP. Then, you can look at it and find out where the problem is. If the slashes are still there, it is obvious that is the issue. Did that make sense?

Let me know. I am gone tonight soon and a lot this weekend… But, I will try to get a look back here for you…

I have changed $albumData =$row[2] as the the field playlist is my third column. You can see the video_alubms fields are albumID albumName playlist albumDescription

I tried everything else and nothing.

stripslahses and addslashes… now we are entering into a very unfamiliar territory for as I have never used them. Can you be more specific as how to use them and where to apply them as well. Thanks… I am curious, is all working on your end?

Also, regarding $albumName=‘Test Playlist1’; as you initialized in in the code…
shouldn’t it be $albumName=’ '; instead?

Since storing complex data, i.e, with lots of characters is always an issue in MySQL, how about creating a playlist more or less like this:

[php]

Loading the player...
[/php]

So, this way only the related field names are pulled from the database. Of course, we would have to make changes to the database structure. This is only an idea as I don’t exactly how to execute it, but I am sure you can.

As you can see a while loop would take care of calling row of data. What do you think?

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

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?

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.

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…

I already updated, and nothing. I see the playlist is not being opulled from the DB.

[php]

testing vid
Loading the player...
[/php]

Take a look at my videos_album table, from a different view. Do you spot anything?

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 )

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]

testing vid <?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... ?>
Loading the player...
[/php]

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.

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…

Sponsor our Newsletter | Privacy Policy | Terms of Service