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.