This idea was based on the player that can be found here
jw_flv_player
I have been trying to find a way with php to automatically to add a preview image to a flv file and after an exhaustive search I have found it. If you know this already, my apologies.
A lot of the credit has to go here though.
http://www.ioncannon.net/php/110/usi...y-annotations/
From there I got the basic code.
I have addded my logo, Mr Rant, to the lower left hand corner.
I also want to be able to pass a file to the player, that I can do. I also am trying to come up with a way to make a way for it to take an xml file and create a playlist.
This is the PHP that I ended up with after some modification:
Code:
function createImage($img) {
$shape = new SWFShape();
$shape->setRightFill($shape->addFill(new SWFBitmap(fopen($img, "rb"))));
if ($img !="rantt.jpg") {
$shape->drawLine(16,0);
$shape->drawLine(0,16);
$shape->drawLine(-16,0);
$shape->drawLine(0,-16);
} else {
$shape->drawLine(80,0);
$shape->drawLine(0,80);
$shape->drawLine(-80,0);
$shape->drawLine(0,-80);
}
return $shape;
}
function createLogo($movie, $name, $loc, $script) {
$button = new SWFButton();
$button->addShape(createImage($name . ".jpg"), SWFBUTTON_UP);
$button->addShape(createImage($name . ".jpg"), SWFBUTTON_DOWN | SWFBUTTON_HIT | SWFBUTTON_OVER);
$button->addAction(new SWFAction($script), SWFBUTTON_HIT);
$item=$movie->add($button);
$item->moveto($loc,180);
}
function createButton($movie, $name, $loc, $script) {
$button = new SWFButton();
$button->addShape(createImage("control_" . $name . ".png"), SWFBUTTON_UP);
$button->addShape(createImage("control_" . $name . "_blue.png"), SWFBUTTON_DOWN | SWFBUTTON_HIT | SWFBUTTON_OVER);
$button->addAction(new SWFAction($script), SWFBUTTON_HIT);
$item=$movie->add($button);
$item->moveto($loc,248);
}
Ming_setScale(10.0000000);
ming_useswfversion(7);
//create our movie object
$movie = new SWFMovie(7);
$movie->setDimension(320,240);
$movie->setBackground('0×33','0×33','0×33');
$movie->setRate(8);
//now we can create our buttons
createButton($movie, "start", 10, "_root.vStream.seek(0);");
createButton($movie, "pause", 40, "_root.vStream.pause(true);");
createButton($movie, "play", 70, "_root.vStream.pause(false);");
createLogo($movie, "rantt", 180,"_root.vStream.pause(false);");
$strAction = "
this.createTextField('video_txt', -1, 0, 0, 100, 100);
video_txt.autoSize = 'left';
video_txt.multiline = true;
video_txt.textColor = 0xeeeeee;
stop();
netConn=new NetConnection();
netConn.connect(null);
vStream=new NetStream(netConn);
video1.attachVideo(vStream);
vStream.setBufferTime(10);
vStream.play(file);//with this we can pass a file to our player
vStream.seek(1);//this is how we generate our preview image without a jpg image
vStream.pause();
videoStream.onCuePoint = function(infoObject)
{
video_txt.text = 'Name: ' + infoObject.name + '\n';
if( infoObject.parameters != undefined )
{
video_txt.text += 'Info: ' + infoObject.parameters['mydata'] + '\n';
}
else
{
video_txt.text += 'Info: undef\n';
}
};
";
$stream = new SWFVideoStream();
$item=$movie->add($stream);
$item->setname("video1");
$movie->add(new SWFAction($strAction));
$movie->nextFrame();
$movie->save("videostream1.swf");
OK, run that once on your server in a dir with write permissions.
You will have a file named videostream1.swf saved there.
Now create the html code. You need to make both the data and value parameters equal to the videostream1.swf now for the file you can pass any flv just by adding the ?file=putwhatevervideohere.flv.
Code:
<div>
<object type="application/x-shockwave-flash" data="http://www.rantnow.net/videostream1.swf?file=http://www.rantnow.net/videos/Simpsons-Opening-Medley.flv" width="300" height="300" id="go"></p>
<param name="movie" value="http://www.rantnow.net/videostream1.swf?file=http://www.rantnow.net/videos/Simpsons-Opening-Medley.flv" />
<param name="quality" value="high" />
</object>
</div>
I am changing the one below to a bikini workout just to show you the difference.
HTML Code:
<object type="application/x-shockwave-flash" data="http://www.rantnow.net/videostream1.swf?file=http://www.rantnow.net/videos/Bikinis-Workouts.flv" width="300" height="300" id="go"></p>
<param name="movie" value="http://www.rantnow.net/videostream1.swf?file=http://www.rantnow.net/videos/Bikinis-Workouts.flv" />
<param name="quality" value="high" />
</object>
You can also see two on one page at
www.rantnow.net/mrrant2.html.