Generate thumbs of video objects ?
Hey guys!
Didn't think this one is getting so tricky ...
I need the first frame of a video-object.
My first guess was to pause the netstream object immediately after the play method and use the seek / close methods when the bufferLength is > 0.1.
But I dont get a picture yet 😕😕 ...
Is there a more effecient way to to that? How do you guys solve that issue when you have to display video-thumbnails?
Thanks a lot
wambo (-:
Code:
public class VideoThumb extends MovieClip
{
private var nc:NetConnection = new NetConnection();
private var ns:NetStream;
private var vid:Video = new Video(200,140);
private var netClient:Object = new Object();
private var prjInfo:ProjectInfo;
private var _duration:Number;
public function VideoThumb(pi:ProjectInfo){
this.prjInfo = pi;
this.buttonMode = true;
/*### VIDEO SETUP ##########*/
this.addChild(vid);
nc.connect(null);
ns = new NetStream(nc);
addChild(vid);
vid.attachNetStream(ns);
ns.play("assets/video/two.flv");
ns.pause();
ns.client = netClient;
netClient.onMetaData = function(meta:Object)
{
trace(meta.duration);
_duration = meta.duration;
};
ns.addEventListener(NetStatusEvent.NET_STATUS, netstat);
this.addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(e:Event):void{
if(ns.bufferLength >= 0.1){
ns.seek(0.1);
ns.close();
this.removeEventListener(Event.ENTER_FRAME, loop);
}
}
}