TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 12-11-2007, 02:01 AM   #1 (permalink)
The Wanderer
 
thegrayman's Avatar
 
Join Date: Dec 2007
Posts: 15
Thanks: 3
thegrayman is on a distinguished road
Default Make Your Own PHP Flash Player Which You Can Pass a File Variable with Preview!!!!

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.

Last edited by thegrayman : 12-11-2007 at 05:35 PM.
thegrayman is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:29 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design