Well, I had a major snag in the code. I tracked it down to a glitch in JW. First, I was not aware it does not play regular videos. Therefore, not one of my tests worked. I finally found this problem. I converted all of my videos to FLV format and they work as they should now. I also came up with a good compact way to handle the “Playlists” with little work… So, to explain it all…
You Videos table would hold all of the info on each video you own or ones that are uploaded by users.
Your PLAYLIST ADMIN page would list all of your videos, however you organized them in the database
and allow you to select multiple ones. This page would include a name for the playlist and other needed
data. There should be a submit button that would “build” the PLAYLIST into the following format:
(Most of the data inside the quotes will be pulled from the database.)
[code]
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???" }
],
[/code]
Your PLAYLIST-CREATOR code would just have to pull your video info and place it into the above code. Then, it would save it in the PLAYLIST database. Not sure how you watch the users to select this playlist, but, it will be very easy to add it to a play-back page. To do this “DYNAMICALLY”, you will need some tricky code. More on that later…
Here is the code that I used for testing. I created 3 test videos with test data and details. I am sure you are familiar with it…
VideoTest.html file:
<!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="jwplayer.js"></script>
<div id="container">Loading the player...</div>
<script type="text/javascript">
jwplayer("container").setup({
flashplayer: "player.swf",
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/Thumbnail3jpg", title: "Testing - Video 3", description: "Dum Dum De Dum.. Drum roll... Another drum roll.. Well? Did it work???" }
],
"playlist.position": "right",
"playlist.size": 360,
height: 270,
width: 720
});
</script>
<body>
</body>
</html>
Copy this code into an HTML file, change the location/names of the videos and thumbnails. Test it and it works well. The above PLAYLIST code can be saved in your PLAYLIST table under a name such as “TEST Playlist”. To “pull” this out of your database, use the following code. Change the server info and database name info to point at your database and tables. Then, run this as a PHP file not HTML. (Which you know about!) I hard-coded the PLAYLIST name for testing. You would, of course get this from the user. (Most likely from the DYNAMIC section which I will send in the next post. I usually place these into a drop-down select list. Easy to do with PHP.) At this point you will have a working video “YouTube”-type display that is pulling the PLAYLIST from your database.
VideoTest.PHP file:
<!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>
<?php
// Set up server connection and open database, ready it for queries...
$hostname='YourWWW.com or other connection string';
$username = "username";
$password = "password";
$dbname = "Playlists";
$dbConn = mysql_connect( $hostname, $username, $password );
@mysql_select_db($dbname);
$PlaylistName="Test Playlist1"; // Temporary test playlist for testing...
$query="SELECT * FROM Playlists WHERE PlaylistName='". $PlaylistName ."'"; // Query the database and load the current playlist
$result = mysql_query ( $query, $dbConn);
$row = mysql_fetch_row($result);
$PlaylistData = $row[1]; // 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="jwplayer.js"></script>
<div id="container">Loading the player...</div>
<script type="text/javascript">
jwplayer("container").setup({
flashplayer: "player.swf",
<?=stripslashes($PlaylistData)?>
"playlist.position": "right",
"playlist.size": 360,
height: 270,
width: 720
});
</script>
<body>
</body>
</html>
**** Note the above, where it prints the PLAYLIST. I used STRIPSLASHES, because you have to store the PLAYLIST in the database with the ADDSLASHES option to take care of quotes and double-qoutes, etc. I am sure you understand that issue. ****
Okay, alter all these code samples and get them working so that it pull your playlist from the database. Make sure to change all of the names to fit your database including the connection strings. Once you are up to that point let me know of any issues. If none, I will send you the DYNAMIC code I use to change these playlists on-the-fly. Since this must be done on the CLIENT-side, it is mostly done in JAVASCRIPT.
Yikes another late night helping people with code… LOL, Hope all this helps…