Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

Auto-Generating Playlist

35 replies [Last post]

I am currently using version 3.11 of the flv player on a video sharing site (not unlike youtube). Thanks for building this player, btw, it is great.

I have been able to successfully use xml playlist files to play a series of specific videos, where everything in the xml file hard points to a specific file. However, I am wanting to do something a little different.

What I would like it to play a short preroll video at the start of each file that is uploaded by a member. So in a way, any time someone uploads a file, it automatically becomes part of a playlist - with that list featuring two files: the preroll and the file that was uploaded.

On the page where videos are displayed, they are called by the simple command:

{$VIDEO_PLAYER}

This command is referring to another file, playme.inc, which contains all of the swf object code. This file looks a little something like this:

<?php

$player_wdith

= 425;
$player_height = 350;
$displayheight = $player_height - 20;

$video_player = <<<EOT

<script type="text/javascript" src="
{$config["baseurl"]}/player/swfobject.js"></script>

<p id="vshare_player"><a href="http://www.macromedia.com/go/getflashplayer">Get Flash</a> to see this player.</p>

<script type="text/javascript">
var so = new SWFObject("

{$config["baseurl"]}/player/player.swf","video_player","$player_wdith","$player_height","8");
so.addParam("allowfullscreen","true");
so.addVariable("file","
{$config["baseurl"]}/flvideo/$video_flvdoname");
so.addVariable("image","
{$config["baseurl"]}/thumb/$video_id.jpg");
so.addVariable("logo","
{$config["baseurl"]}/templates/images/watermark.gif");
so.addVariable("link","
{$config["watermark_url"]}");
so.addVariable("linktarget","_blank");
so.addVariable("width","$player_wdith");
so.addVariable("height","$player_height");
so.addVariable("displayheight","$displayheight");
so.addVariable("bufferlength", "5");
so.addVariable("overstretch", "true");
so.addVariable("autostart", "false");
so.write('video_player');
</script>

EOT;

?>

My initial attempt was to simply substitute the "file" command in the playme.inc with the path to an xml playlist, which would contain the $video_flvdoname in the playlist. So, I ended up with something a little like this:

<playlist version="1" xmlns="http://xspf.org/ns/0/">
  <title>Standard Playlist</title>
  <info>http://www.mysite.com</info>
  <annotation>Standard Playlist File</annotation>
<trackList>
<track>
  <title>Preroll</title>
  <location>>{$config["baseurl"]}/flvideo/preroll.flv</location>
  <info>http://www.mysite.com/</info>
  <album>preroll</album>
  </track>
<track>
  <title>Member Video</title>
  <creator>Member Upload</creator>
  <location>{$config["baseurl"]}/flvideo/$video_flvdoname</location>
  <image>{$config["baseurl"]}/thumb/$video_id.jpg</image>
  </track>
  </trackList>
  </playlist>

I honestly thought that would do the trick, but it did not. Nothing plays. I was then told that maybe I should try doing this with php instead of xml. I am a bit of a novice with php - I eventually figure things out but it takes some time. I tried a couple of things, but I still couldn't get it to work at all.

Does anyone have any idea where I am going wrong? Any nudge in the right direction would be greatly appreciated.

To start, any php vars inside the JS needs to be wrapped in <?php echo tags, not the whole js wrapped in php, ie:

<?php

$player_wdith

= 425;
$player_height = 350;
$displayheight = $player_height - 20;

$video_player = <<<EOT
?>

<script type="text/javascript" src="<?php echo {$config["baseurl"]}; ?>/player/swfobject.js"></script>

<p id="vshare_player"><a href="http://www.macromedia.com/go/getflashplayer">Get Flash</a> to see this player.</p>

<script type="text/javascript">
var so = new SWFObject("<?php echo {$config["baseurl"]}; ?>/player/player.swf","video_player","<?php echo $player_wdith; ?>","<?php echo $player_height; ?>","8");
so.addParam("allowfullscreen","true");
so.addVariable("file","{$config["baseurl"]}/flvideo/<?php echo $video_flvdoname; ?>");
so.addVariable("image","{$config["baseurl"]}/thumb/<?php echo $video_id; ?>.jpg");
so.addVariable("logo","{$config["baseurl"]}/templates/images/watermark.gif");
so.addVariable("link","{$config["watermark_url"]}");
so.addVariable("linktarget","_blank");
so.addVariable("width","<?php echo $player_wdith; ?>");
so.addVariable("height","<?php echo $player_height; ?>");
so.addVariable("displayheight","<?php echo $displayheight; ?>");
so.addVariable("bufferlength", "5");
so.addVariable("overstretch", "true");
so.addVariable("autostart", "false");
so.write('video_player');
</script>

<?php
EOT
;

?>

etc., etc.

As to the playlist, you probably need to rename it with a php ext and do the same with it. Player really doesn't care what the file is called, as long as it finds proper xml markup playlist.

Let us know if this gets you started in the right direction.

If I was doing that many PHP variables, I would put the whole thing in PHP like JerryG did.

PHP is just being used as a dumb printer to output an HTML doc. with frequent replacement of a variable with it's current value. The resulting HTML doc. woud be indistinguishable from one that I typed, 'cept for a lot of typOs!

JerryG, Your 'file' flashvar in the HTML should look like this:

so.addVariable("file",escape("http://my.domain.com/path/playlist_generator.php?file=video_filename)");

where playlist_generator.php?file=video_filename refers to a PHP script that generates an XML playlist similar to what you have posted above. When served to the JW Player, that XML playlist would have the PHP variables replaced by their values, again indistinguishable from the one that I typed (no typOs allowed!).

Set it up like this and if you still are having trouble, post a link (BEST) or at least all of your code and I'll "push" you some more in the right direction. :)

Misplaced right parenthesis:

so.addVariable("file",escape("http://my.domain.com/path/playlist_generator.php?file=video_filename<strong>"));</strong>

First of all, thank both of you very much for taking the time to type a reply. I honestly do appreciate it very much.

I started out with Dan's suggestion of wrapping all of those items, but when I did that, the only thing that was displayed was a ?> where the player would normally be at. I tried removing the first ?> and last <?php and then all I would get was the message prompting me to install flash. I noticed that there was an error stating the swfobject wasn't defined.

Thinking I must have missed something, I came back here to double check, and that's when I saw Will's reply. I noticed the parenthesis and moved that. I still seem to be having trouble, but I think I am at least on the right track. I think the problem must be with the file that have the playlist in. For now, I have that file named testlist.php - so the 'file' flashvar is currently set as:

so.addVariable("file",escape("http://www.sportsgamingtv.com/testlist.php?file=video_filename") );

I'm certain that it is this testlist.php that is giving me grief. I've tried changing it up a number of different ways:

- the entire file enclosed with <?php and ?>
- the $ prompts wrapped with <?php echo and ; ?> (but not the whole file being within <?php
- both of the above at the same time
- neither of the above

When I tried neither of the above, that got the closest result, in that it would play the first file (direct linked to an flv), but noth the one that uses $video_flvdoname (obviously, since it did not contain <?php anywhere. Even though it was wrong, I was still happy to at least see something play. lol.

After that I got desparate, and wrapped the entire file with <?php again, and the opened each line of the document with echo " and closed each line with \n"; That did not work either.

As it stands right now, I have the testlist.php set as:

<?php

<playlist version="1" xmlns="http://xspf.org/ns/0/">
<
title>Standard Playlist</title>
<
info>http://www.sportsgamingtv.com</info>
<annotation>Standard Playlist File</annotation>
<
trackList>
<
track>
<
title>Sports Gaming TV</title>
<
location>http://www.sportsgamingtv.com/flvideo/118824154064749921.flv</location>
<info>http://www.sportsgamingtv.com/</info>
</track>
<
track>
<
title>Member Video</title>
<
creator>Sports Gaming TV</creator>
<
location>http://www.sportsgamingtv.com/flvideo/$video_flvdoname</location>
<image>http://www.sportsgamingtv.com/thumb/$video_flvdoname</image>
</track>
</
trackList>
</
playlist>

?>

The result of this list is that the player does not come up at all. In what would be the upper left corner of the player (if it were there), you can see the circular image that displays when a video is loading (under normal conditions), but nothing else.

I'm not entirely sure what I've done wrong. I'll have to take some time to think it over. In the mean time, I'll leave it in place 'as is' in case my description of what is being displayed is too confusing - that way you can see the result first hand. I'll leave it like that for a while and revert it back to the "normal" mode later on. Until then, you can see what I mean by clicking on any of the videos at sportsgamingtv.com

I feel like I'm on the right track with this, I'm just not entirely certain what I'm doing wrong.

Anyway, thanks again for taking the time to look at this and to read such insanely lengthy posts. Even if I never figure this out, I still appreciate your efforts very much.

Put echo tags around it. Single quote any doubles-quotes inside your echo statement. Like this:

<?php
echo "
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
<title>Standard Playlist</title>
<info>http://www.sportsgamingtv.com</info>
<annotation>Standard Playlist File</annotation>
<trackList>
<track>
<title>Sports Gaming TV</title>
<location>http://www.sportsgamingtv.com/flvideo/118824154064749921.flv</location>
<info>http://www.sportsgamingtv.com/</info>
</track>
<track>
<title>Member Video</title>
<creator>Sports Gaming TV</creator>
<location>http://www.sportsgamingtv.com/flvideo/$video_flvdoname</location>
<image>http://www.sportsgamingtv.com/thumb/$video_flvdoname</image>
</track>
</trackList>
</playlist>
"
;
?>

testlist.php

<?php

$video_flvdoname

= (isset($_GET['file'])) ? strval($_GET['file']) : 'video.flv';

if (

strpos($video_flvdoname, '.flv') === false)
{
 
$video_flvdoname = $video_flvdoname . '.flv';
}

$video_flvdoname = 'http://www.sportsgamingtv.com/flvideo/' . $video_flvdoname;

print <<<END

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

<playlist version="1" xmlns="http://xspf.org/ns/0/">
  <title>Standard Playlist</title>
  <info>http://www.sportsgamingtv.com</info>
  <annotation>Standard Playlist File</annotation>
  <trackList>
    <track>
      <title>Sports Gaming TV</title>
      <location>http://www.sportsgamingtv.com/flvideo/118824154064749921.flv</location>
      <info>http://www.sportsgamingtv.com/</info>
    </track>
    <track>
      <title>Member Video</title>
      <creator>Sports Gaming TV</creator>
      <location>$video_flvdoname</location>
      <image>$video_flvdoname</image>
    </track>
  </trackList>
</playlist>
END;

?>

call with:

so.addVariable("file",escape("http://www.sportsgamingtv.com/flvideo/testlist.php?file=118824154064749921"));

So we don't fool the the parser into thinking that it's getting a FLV video file, we've left off the filename extension ".flv" and are adding it back on in "testlist.php".

Call it from your browser, like this:

http://www.sportsgamingtv.com/flvideo/testlist.php?file=118824154064749921

and it will spew out this:

<?xml version='1.0' encoding='UTF-8'?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
  <title>Standard Playlist</title>
  <info>http://www.sportsgamingtv.com</info>
  <annotation>Standard Playlist File</annotation>
  <trackList>
    <track>
      <title>Sports Gaming TV</title>
      <location>http://www.sportsgamingtv.com/flvideo/118824154064749921.flv</location>
      <info>http://www.sportsgamingtv.com/</info>
    </track>
    <track>
      <title>Member Video</title>
      <creator>Sports Gaming TV</creator>
      <location>http://www.sportsgamingtv.com/flvideo/118824154064749921.flv</location>
      <image>http://www.sportsgamingtv.com/flvideo/118824154064749921.flv</image>
    </track>
  </trackList>
</playlist>

You also need to do something about the path in the <image> element so it points to an image, not the video file, but that's trivial.

Many thanks to both of you, once again. I'll read all of this again as soon as I can and report back with how it goes. Honestly, I can't thank you enough for your help.

@JerryG,

Before you go putting too much effort into re-inventing this wheel...

There are many highly developed playlist generators already available on these forums and elsewhere. If you can give us the exact details of what you want to do, I will post some code to do it. :)

Then you can spend your time on other aspects of your site.

Ok, I guess I couldn't wait that long.

I tried both ways. First I left the "file" flashvar as it was, and just changed the testlist.php to the way Dan set it, with the whole thing wrapped in the echo.

This was a partial success. I could see the player, and it did play the first file, just not the second. Still, it was a major improvement.

Then I switched over to Will's suggestion. I basically just copy and pasted the exact code posted (except I took out the image tag for now) into a new document named playlist.php and uploaded it into the flvideo folder. Then I changed the file flashvar to be:

so.addVariable("file",escape("http://www.sportsgamingtv.com/flvideo/playlist.php?file=118824154064749921"));

With this, I got the same result. I could thankfully see the player, and it played the first video in the file, but not the second. Then I thought maybe it would work if I took ?file=118824154064749921 out of the flashvar, so I tried that. That was odd because sometimes it would play the first video, sometimes it wouldn't. Maybe it was something in my cache causing that. I'm not sure, so I reverted it back to the way it was.

So anyway, I guess I will still keep wracking my brain to try to figure out what is going on here, but this is a MAJOR improvement. A big step in the right direction anyway, and even though I dont understand the problem, I am at least have more optimism.

Thank you both once again. Your help has been spectacular.

@JerryG,

If I go to this URL: http://www.sportsgamingtv.com/flvideo/playlist.php?file=118824154064749921 I get a valid playlist that looks like this:

<?xml version='1.0' encoding='UTF-8'?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Standard Playlist</title>
<info>http://www.sportsgamingtv.com</info>
<annotation>Standard Playlist File</annotation>
<trackList>
<track>
<title>Sports Gaming TV</title>
<location>http://www.sportsgamingtv.com/flvideo/118824154064749921.flv</location>
<info>http://www.sportsgamingtv.com/</info>
</track>
<track>
<title>Member Video</title>
<creator>Sports Gaming TV</creator>
<location>http://www.sportsgamingtv.com/flvideo/118824154064749921.flv</location>
</track>
</trackList>
</playlist>

both of the <location> elements have the EXACT same URL
http://www.sportsgamingtv.com/flvideo/118824154064749921.flv
which does deliver a good FLV video file. So, your playlist is OK.

Next, check your player code.

The problem lies in a mis-match of the placeholder id and the SWFObject id.

<p id="<strong>vshare_player</strong>"><a href="http://www.macromedia.com/go/getflashplayer">Get Flash</a> to see this player.</p>

<script type="text/javascript">
var so = new SWFObject("<?php echo {$config["baseurl"]}; ?>/player/player.swf","video_player","<?php echo $player_wdith; ?>","<?php echo $player_height; ?>","8");
so.addParam("allowfullscreen","true");
so.addVariable("file","{$config["baseurl"]}/flvideo/<?php echo $video_flvdoname; ?>");
so.addVariable("image","{$config["baseurl"]}/thumb/<?php echo $video_id; ?>.jpg");
so.addVariable("logo","{$config["baseurl"]}/templates/images/watermark.gif");
so.addVariable("link","{$config["watermark_url"]}");
so.addVariable("linktarget","_blank");
so.addVariable("width","<?php echo $player_wdith; ?>");
so.addVariable("height","<?php echo $player_height; ?>");
so.addVariable("displayheight","<?php echo $displayheight; ?>");
so.addVariable("bufferlength", "5");
so.addVariable("overstretch", "true");
so.addVariable("autostart", "false");
so.write('<strong>video_player</strong>');
</script>

The two items in bold ABSOLUTELY MUST BE THE SAME !!!

There are many highly developed playlist generators already available on these forums and elsewhere. If you can give us the exact details of what you want to do, I will post some code to do it.

--

Thanks. I looked through quite a few generators, but all of the ones I came across were for putting together static play lists. I really need something more dynamic, I guess is the best way to describe it.

The way things are set up right now, I have one file, view_video.php (which uses a view_video.tpl template) that is used by every video uploaded. That file only calls the video dynamically as {$VIDEO_PLAYER} which is defined by the player.inc file mentioned in the original post. This inc file (under /includes) is also where all the flashvars are getting changed at.

So basically, when you click on a link to watch a video someone uploads, you are actually not going to the url you see, but are hitting the view_video.php, which dynamically calls the .inc file, which I am trying to use in conjunction with a play list so that every video will always be preceded by (and/or followed by) the same site identification or commercial clips.

Geez, I hope that makes some sense, because it comes across as looking really confusing to me, and I already know what I'm saying (sorta).

So anyway, the end point is that the way the site works, the videos are only referenced by $video_flvdoname (unless I'm overlooking something), and it didn't seem possible to incorporate that into any of the playlist generators that I encountered. They all wanted to crawl a directory and put together a large list of files, which is a little different than what I need it to do.

I'll have to keep looking. Perhaps there is something I am overlooking somewhere. It's not the end of the world either way - just one of those things that drives you batty when it should be simple but turns out to be complicated.

If I go to this URL: http://www.sportsgamingtv.com/flvideo/playlist.php?file=118824154064749921 I get a valid playlist that looks like this:

That is also what I see when I type that in. That was confusing to me, because if you look, both items in the playlist reference the same flv file (which may be why I am only seeing the first file in the sequence). The second one should be different, and would vary depending on the specific video being watched. Or maybe that is what would happen if I was on a page to watch a video, rather than just typing in that url.

The two items in bold ABSOLUTELY MUST BE THE SAME !!!

The one I am using is all in sync (I believe). I'll go over it again just to make sure, but this is what I have:

player.inc

<?php

$player_wdith

= 425;
$player_height = 350;
$displayheight = $player_height - 20;

$vshare_player = <<<EOT

<script type="text/javascript" src="
{$config["baseurl"]}/player/swfobject.js"></script>

<p id="vshare_player"><a href="http://www.macromedia.com/go/getflashplayer">Get Flash</a> to see this player.</p>

<script type="text/javascript">
var so = new SWFObject("

{$config["baseurl"]}/player/player.swf","vshare_player","$player_wdith","$player_height","8");
so.addParam("allowfullscreen","true");
so.addVariable("file",escape("http://www.sportsgamingtv.com/flvideo/playlist.php?file=118824154064749921"));
so.addVariable("image","
{$config["baseurl"]}/thumb/$video_id.jpg");
so.addVariable("logo","
{$config["baseurl"]}/templates/images/watermark.gif");
so.addVariable("link","
{$config["watermark_url"]}");
so.addVariable("linktarget","_blank");
so.addVariable("width","$player_wdith");
so.addVariable("height","$player_height");
so.addVariable("displayheight","$displayheight");
so.addVariable("bufferlength", "5");
so.addVariable("overstretch", "true");
so.addVariable("autostart", "false");
so.write('vshare_player');
</script>

EOT;

?>

playlist.php

<?php

$video_flvdoname

= (isset($_GET['file'])) ? strval($_GET['file']) : 'video.flv';

if (

strpos($video_flvdoname, '.flv') === false)
{
$video_flvdoname = $video_flvdoname . '.flv';
}

$video_flvdoname = 'http://www.sportsgamingtv.com/flvideo/' . $video_flvdoname;

print <<<END

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

<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Standard Playlist</title>
<info>http://www.sportsgamingtv.com</info>
<annotation>Standard Playlist File</annotation>
<trackList>
<track>
<title>Sports Gaming TV</title>
<location>http://www.sportsgamingtv.com/flvideo/118824154064749921.flv</location>
<info>http://www.sportsgamingtv.com/</info>
</track>
<track>
<title>Member Video</title>
<creator>Sports Gaming TV</creator>
<location>$video_flvdoname</location>
</track>
</trackList>
</playlist>
END;

?>

It looks like it all matches up. I'm baffled as to why I am having any trouble.

@JerryG,

Actually, all of the playlist generators are dynamic.

When the user loads the JW Player, the player requests a playlist from the server. The server generates the playlist right then, can't get any more dynamic that that.

The generated playlists can also be double-dynamic, the generated <location> element can be a link to a redirect script that will select any of thousands of available links, based upon information that is sent when that particular file is requested.

The code I posted uses $video_flvdoname to determine which exact video file to reference in the <location> element, so I don't know what more you are looking for. More details are needed... ;)

@JerryG,

Change the number 118824154064749921 in this URL http://www.sportsgamingtv.com/flvideo/playlist.php?file=118824154064749921 and I guarantee you that you will get a second, different file in your playlist. Make it a valid filename and you can watch two videos. That's how it works. That's dynamic. :) So when you generate the player code in "playme.inc" with a different number, the user will request that different file from your server.

You can't have this line in your player code when you are using a playlist because file, author, title, image, type, etc ALL have to come from the playlist.

Lose this:

so.addVariable("image","{$config["baseurl"]}/thumb/$video_id.jpg");

The rest of the code looks good, but I've got to test it off of your server. So let me know when your video player page is up. Or give me a link to a test page.

@JerryG,

Also, this has to come from the <info> element of the playlist:

http://www.jeroenwijering.com/extras/readme.html#playlists

You can see all of the flashvar/playlist element ewquivalents here [url=http://www.jeroenwijering.com/extras/readme.html#playlists]PLAYLISTS[/url]

I checked your player page, other than the link, it looks good. Now put some dynamic file name numbers in it and you should be "good to go".

Lose this:

so.addVariable("image","{$config["baseurl"]}/thumb/$video_id.jpg");

Thanks, I did take that out.

When I look at this, what I keep coming back to is this:

so.addVariable("file",escape("http://www.sportsgamingtv.com/flvideo/playlist.php?file=118824154064749921"));

I had assumed that the ?file=118824154064749921 was included because it is the first file in the playlist, since I had the first file listed as 118824154064749921.flv (which is just a short preroll logo for testing).

I had originally thought I was watching the first video in the playlist, but not the second. Now I think that this is not the case, and that this code is just telling the player to load that particular file (118824154064749921.flv). I say this because I revised the playlist.php to be:

<?php

$video_flvdoname

= (isset($_GET['file'])) ? strval($_GET['file']) : 'video.flv';

if (

strpos($video_flvdoname, '.flv') === false)
{
$video_flvdoname = $video_flvdoname . '.flv';
}

$video_flvdoname = 'http://www.sportsgamingtv.com/flvideo/' . $video_flvdoname;

print <<<END

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

<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Standard Playlist</title>
<info>http://www.sportsgamingtv.com</info>
<annotation>Standard Playlist File</annotation>
<trackList>
<track>
<title>Member Video</title>
<creator>Sports Gaming TV</creator>
<location>$video_flvdoname</location>
</track>
<track>
<title>Sports Gaming TV</title>
<location>http://www.sportsgamingtv.com/flvideo/118824154064749921.flv</location>
<info>http://www.sportsgamingtv.com/</info>
</track>
</trackList>
</playlist>
END;

?>

As you can see, with that playlist, 118824154064749921.flv should be played last, and whatever the uploaded file is ($video_flvdoname) should be played first, right? But then if you go here (random video selected):

http://www.sportsgamingtv.com/view/23/arkansas-razorbacks-history/

With the playlist above, you should be seeing the arkansas razorbacks video first, but it does not play at all. You still see the 118824154064749921.flv

So I'm wonder if that file flashvar is somehow just telling the player to load that one specific file (118824154064749921.flv). I could probably remove it from the playlist file entirely and that's still what would load.

Ok, I actually did just remove that file from the playlist, and that's still what I'm having displayed, so at least I have another small piece of the puzzle now.

Also, this has to come from the <info> element of the playlist:

http://www.jeroenwijering.com/extras/readme.html#playlists

You can see all of the flashvar/playlist element ewquivalents here PLAYLISTS

Sorry, but I had missed this post until now. We were probably posting at the same time or something. I have removed anything from that list except for the basics, so what I have on there right now is:

var so = new SWFObject("{$config["baseurl"]}/player/player.swf","vshare_player","$player_wdith","$player_height","8");
so.addParam("allowfullscreen","true");
so.addVariable("file",escape("http://www.sportsgamingtv.com/flvideo/playlist.php?file=118824154064749921"));
so.addVariable("width","$player_wdith");
so.addVariable("height","$player_height");
so.addVariable("displayheight","$displayheight");
so.addVariable("bufferlength", "5");
so.addVariable("overstretch", "true");
so.addVariable("autostart", "false");
so.write('vshare_player');

So there shouldn't be any conflict with anything there.

I checked your player page, other than the link, it looks good. Now put some dynamic file name numbers in it and you should be "good to go".

At the risk of sounding like a total idiot, I am not entirely sure what you mean. The purpose of the $video_flvdoname is to generate the file name dynamically. I'm not sure what more I can do other than putting that in. If I have to manually put in the files for each one, that would be static and be way too time consuming. I think I'm just not understanding you though.

As I said in the last post though, I think I'm not even playing the playlist file. I have stripped it all the way down to this:

<?php

$video_flvdoname

= (isset($_GET['file'])) ? strval($_GET['file']) : 'video.flv';

if (

strpos($video_flvdoname, '.flv') === false)
{
$video_flvdoname = $video_flvdoname . '.flv';
}

$video_flvdoname = 'http://www.sportsgamingtv.com/flvideo/' . $video_flvdoname;

print <<<END

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

<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Standard Playlist</title>
<info>http://www.sportsgamingtv.com</info>
<annotation>Standard Playlist File</annotation>
<trackList>
<track>
<title>Member Video</title>
<creator>Sports Gaming TV</creator>
<location>$video_flvdoname</location>
</track>
</trackList>
</playlist>
END;

?>

As you can see, 118824154064749921.flv is not even in the playlist any longer, but that is still what gets played. I think I'm not even getting to the playlist file at all for some reason. I'll have to focus on something else for a while and revisit this with a fresh mind.

Thanks anyway for all of the help that you have given. I know the answer is there, but it's just not presenting itself properly.

As you can see, 118824154064749921.flv is not even in the playlist any longer, but that is still what gets played. I think I'm not even getting to the playlist file at all for some reason.

If you are just refreshing your page, don't rely on this to reload a new playlist. Not even <<shift>> refresh is positive. Have discovered that to be really sure after a change, close your browser and reopen the player. Just a thought. :)

Yeah, I tried that, even used a different browser entirely. Not sure what to make of it. This php stuff is kicking my butt. *)

As an experiment, I changed the flashvar to:

so.addVariable("file",escape("http://www.sportsgamingtv.com/flvideo/playlist.php?file=11875182991788318185"));

The result was that 11875182991788318185.flv is the video that gets played, regardless of what videos are in the playlist or what video you try to view. What is in that flashvar is what you see.

So I'm at a loss. If I put a file name in, that file is played in place of any other video on the site. If I take out the file= portion, then nothing plays. *)

I dont see how you guys maintain your sanity. lol

@JerryG,

Yeah, I don't think I've had much sanity for quite a while...

The result was that 11875182991788318185.flv is the video that gets played, regardless of what videos are in the playlist or what video you try to view.

This is exactly what is supposed to happen.

You are requesting that "playlist.php" make a playlist with the first video file your static content, ads or whatever, and the second file is the file that you told playlist.php to use for the second file in the playlist.

If you want some other behavior, what is it?????

This is exactly what is supposed to happen.

You are requesting that "playlist.php" make a playlist with the first video file your static content, ads or whatever, and the second file is the file that you told playlist.php to use for the second file in the playlist.

If you want some other behavior, what is it?????

That doesn't really seem to be what is happening though. It is simply loading that one file and nothing else, regardless of what is in the playlist.php file.

If it is not due to the ?file=118824154064749921 aspect of the flashvar, then it must be a problem with the playlist itself. I think I may have found what that problem is, but am not entirely sure.

You will recall that we were working around $video_flvdoname. I felt that this was correct because it is how the original flashvar called up the file. But maybe that is where the problem is. So I went back to the view_video template that generates the page a person sees when they click on the video. The top of the file starts with this:

{insert name=video_info assign=vinfo vid=$VID}

I went down to the section where the embeddable code is generated, and this is what it has:

<span style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; padding-bottom: 2px; PADDING-TOP: 2px; BACKGROUND-COLOR: #ffffaa">
Embeddable Player:</SPAN>

<br /> <br />
<input NAME="video_play" value='{if $embed_type eq "0"}<iframe vspace="0" hspace="0" allowtransparency="true" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" style="border:0px;" width="435" height="470" SRC="{$baseurl}/show.php?id={$vinfo[0].VID}"></iframe>{else}

<object width="425" height="350" type="application/x-shockwave-flash" data="{$baseurl}/player/player.swf"><param name="movie" value="{$baseurl}/player/player.swf" /><param name="flashvars" value="&file={$baseurl}/flvideo/{$vinfo[0].flvdoname}&height=350&image={$baseurl}/thumb/{$vinfo[0].VID}.jpg&width=425&location={$baseurl}/player/player.swf&logo={$baseurl}/templates/images/watermark.gif&link={$watermark_url}&linktarget=_blank"/></object>{/if}' size="60" onclick=javascript:document.linkForm.video_play.focus();document.linkForm.video_play.select(); readOnly>

<div style="font-size: 11px"> (Put this video on your website. Works on Friendster, eBay, Blogger, MySpace!)
<br />
<br />
</div>

Basically, the part where this code generates the file name that gets played is where is this:

&file={$baseurl}/flvideo/{$vinfo[0].flvdoname}

So perhaps instead of $video_flvdoname maybe I should be working with $vinfo[0].flvdoname instead.

What do you think?

@JerryG,

Yes, you are on the right track.

Whatever code generates the finished page for the user has to put the new filename (in your case it's a long number, but it is still the filename) in this finished code:

so.addVariable("file",escape("http://www.sportsgamingtv.com/flvideo/playlist.php?file=<strong>new filename goes here</strong>"));

So I would try this in player.inc:

so.addVariable("file",escape("{$config["baseurl"]}/flvideo/playlist.php?file={$vinfo[0].flvdoname}"));

Breaking it down:

{$config["baseurl"]} should give: http://www.sportsgamingtv.com

then you have: /flvideo/playlist.php?file=

then {$vinfo[0].flvdoname} should give: 118824154064749921.flv

for a complete URL of: http://www.sportsgamingtv.com/flvideo/playlist.php?file=118824154064749921.flv

And now we have a BIG problem because the file extension ".flv" is back, so we are going to have to get rid of the extension before we can use the filename.

So in player.inc you will have to add this code: (in bold)

<?php

$player_wdith = 425;
$player_height = 350;
$displayheight = $player_height - 20;
<strong>$filename = substr({$vinfo[0].flvdoname}, 0, (strlen({$vinfo[0].flvdoname}) - 4));</strong>

which will turn 118824154064749921.flv into 118824154064749921

And then use this player code:

so.addVariable("file",escape("{$config["baseurl"]}/flvideo/playlist.php?file=$filename"));

which should yield a "file" URL of: http://www.sportsgamingtv.com/flvideo/playlist.php?file=118824154064749921

with no ".flv" extension.

The only problem I see with that is that I still want 118824154064749921.flv to be the first file played in the playlist, and then after that the file called up by $vinfo[0].flvdoname to play. So I think that $vinfo[0].flvdoname should be called up in the playlist.php file (unless I am totally misunderstanding this).

What would happen if I left the file flashvar as:

so.addVariable("file",escape("http://www.sportsgamingtv.com/flvideo/playlist.php?file=118824154064749921"));

And then opened playlist.php and changed every instance of $video_flvdoname to be $vinfo[0].flvdoname

So what the playlist file would look like is:

<?php

$vinfo

[0].flvdoname = (isset($_GET['file'])) ? strval($_GET['file']) : 'video.flv';

if (

strpos($vinfo[0].flvdoname, '.flv') === false)
{
$vinfo[0].flvdoname = $vinfo[0].flvdoname . '.flv';
}

$vinfo[0].flvdoname = 'http://www.sportsgamingtv.com/flvideo/' . $vinfo[0].flvdoname;

print <<<END

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

<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Standard Playlist</title>
<info>http://www.sportsgamingtv.com</info>
<annotation>Standard Playlist File</annotation>
<trackList>
<track>
<track>
<title>Sports Gaming TV</title>
<location>http://www.sportsgamingtv.com/flvideo/118824154064749921.flv</location>
<info>http://www.sportsgamingtv.com/</info>
</track>
<title>Member Video</title>
<creator>Sports Gaming TV</creator>
<location>$vinfo[0].flvdoname</location>
</track>
</trackList>
</playlist>
END;

?>

Does that look reasonable, or does it look like something that will just jumble me up again?

I suppose I should just try it and see, because even the things that do look reasonable turn out to be something unexpected, for some crazy reason that eludes me.

---

Ok, that didn't exactly work. It put me back to where I use to be when the player didn't load up and I just got the image that plays when something is loading. It was worth a shot I guess.

@JerryG,

You are confusing the example file names being used here with actual filenames.

Put the actual file name of the video file that you want to play first, whatever it is, in the first track of the playlist.

Then use the $filename variable as the filename in the second track of the playlist. I don't want to use $vinfo[0].flvdoname because I don't want it to be confused with the $vinfo[0].flvdoname variable that is being used in player.inc.

If the actual filename for track one = 118824154064749921.flv, then your playlist.php will look like this:

<?php

$filename

= (isset($_GET['file'])) ? strval($_GET['file']) : 'video.flv';

if (

strpos($filename, '.flv') === false)
{
$filename = $filename . '.flv';
}

$filename = 'http://www.sportsgamingtv.com/flvideo/' . $filename;

header("content-type:text/xml;charset=utf-8");

print <<<END

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

<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Standard Playlist</title>
<info>http://www.sportsgamingtv.com</info>
<annotation>Standard Playlist File</annotation>
<trackList>
<track>
<title>Sports Gaming TV</title>
<location>http://www.sportsgamingtv.com/flvideo/<strong>118824154064749921.flv</strong></location>
<info>http://www.sportsgamingtv.com/</info>
</track>
<track>
<title>Member Video</title>
<creator>Sports Gaming TV</creator>
<location>$filename</location>
</track>
</trackList>
</playlist>
END;

?>

Note that I have also added the proper header to playlist.php.

In player.inc if $vinfo[0].flvdoname = 123456789.flv, then the request from the player to playlist.php will look like this:

http://www.sportsgamingtv.com/flvideo/playlist.php?file=123456789

and playlist.php will return a playlist that looks like this:

<?xml version='1.0' encoding='UTF-8'?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Standard Playlist</title>
<info>http://www.sportsgamingtv.com</info>
<annotation>Standard Playlist File</annotation>
<trackList>
<track>
<title>Sports Gaming TV</title>
<location>http://www.sportsgamingtv.com/flvideo/<strong>118824154064749921.flv</strong></location>
<info>http://www.sportsgamingtv.com/</info>
</track>
<track>
<title>Member Video</title>
<creator>Sports Gaming TV</creator>
<location>http://www.sportsgamingtv.com/flvideo/<strong>123456789.flv</strong></location>
</track>
</trackList>
</playlist>

I dont really think I'm confusing anything. Aside from a new header line, the only difference between this playlist file and the other is that we've swapped out a variable that the scripts know with one that is new. I get the same result - I play the first file but not the second.

It's not that I am not understanding so much as it is that this just simply isn't working. For what reason it is not working is a mystery to me. I'm basically a novice at php, but it looks like everything is being referenced properly, so I'm not sure what the hang up is unless it is in another file somewhere that I do not know about.

Anyway, I do appreciate all of your attempts to help me in this matter. I am at a loss as to why it is so difficult. It all seems logical to me, so if this isn't getting it accomplished, I'm not sure what will. Perhaps this is just something that is not meant to be until some point later on when I can take the time to have someone go over all the code of this script and figure out what the problem is.

Thank you for all of your help Will. You've been very patient through this.

Hello!

I'm from Portugal and i need your help for one thing? It is possible with this flv player, to reload a xml playlist automatically without reload the page?
Why i won't that?
For example: you are watching the videos with a playlist and at the same time a put another video in the playlist, at the end or in the begining of the playlist. What i won't to know is that if there are a way to reload a video playlist automatically without reload a page? Or a way to reload automatically the playlist when all files are played?

Please help me... someone.

Thanks

@Philippe,

See the examples here: [url=http://www.jeroenwijering.com/extras/javascript.html]JAVASCRIPT CONTROL EXAMPLES[/url]

I saw the examples, but i think anyone can help me.
For example, you are watching the video playlist and at the same time i put another video in the playlist... what i need is that the flvplayer automatically update the playlist, without a need of a javascript button, that you (the video watcher) have to puch to update the playlist.
Sorry my english... i hope you can understand what i need.
Thanks for your help ;)

@Philippe - how about just reloading the playlist everytime the player has finished playing?
for that you can use the "state" variable and check if the value is 3 and if - then update the playlist...
for code - please see the [url=http://home5.inet.tele.dk/nyboe/flash/mediaplayer/redirect.htm]redirect[/url] examples on the [url=http://home5.inet.tele.dk/nyboe/flash/mediaplayer/]demopage[/url] - just load instead of redirect

What would happen if I left the file flashvar as:

so.addVariable("file",escape("http://www.sportsgamingtv.com/flvideo/playlist.php?file=118824154064749921"));

And then opened playlist.php and changed every instance of $video_flvdoname to be $vinfo[0].flvdoname

So what the playlist file would look like is:

<?php

$vinfo[0].flvdoname = (isset($_GET['file'])) ? strval($_GET['file']) : 'video.flv';

if (strpos($vinfo[0].flvdoname, '.flv') === false)
{
$vinfo[0].flvdoname = $vinfo[0].flvdoname . '.flv';
}

$vinfo[0].flvdoname = 'http://www.sportsgamingtv.com/flvideo/' . $vinfo[0].flvdoname;

print <<<END
<?xml version='1.0' encoding='UTF-8'?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Standard Playlist</title>
<info>http://www.sportsgamingtv.com</info>
<annotation>Standard Playlist File</annotation>
<trackList>
<track>
<track>
<title>Sports Gaming TV</title>
<location>http://www.sportsgamingtv.com/flvideo/118824154064749921.flv</location>
<info>http://www.sportsgamingtv.com/</info>
</track>
<title>Member Video</title>
<creator>Sports Gaming TV</creator>
<location>$vinfo[0].flvdoname</location>
</track>
</trackList>
</playlist>
END;

?>

Does that look reasonable, or does it look like something that will just jumble me up again?

Thanks for the info, really helpful
[url=http://www.jurugan.com]Daily Health[/url]

<script type='text/javascript' src='http://www.jeroenwijering.com/embed/swfobject.js'></script>

<div id='preview'>This div will be replaced</div>

<script type='text/javascript'>
var s1 = new SWFObject('/embed/player.swf','ply','470','320','9','#ffffff');
s1.addParam('allowfullscreen','true');
s1.addParam('allowscriptaccess','always');
s1.addParam('wmode','opaque');
s1.addParam('flashvars','file=http://content.bitsontherun.com/videos/qyehIiBT.flv&image=http://content.bitsontherun.com/thumbs/qye...');
s1.write('preview');
</script>

JerryG,
Your video playlist, does it play the next video automatically, or does the user need to click on the next video? I am looking for a solution that will go to the next video automatically but I don't know how to trigger when the video ends.

@Sean - With the JW Player if you set the "repeat" flashvar to "always" the playlist will go from one item to another.