How to make an FLV component to play videos automatically
nikolaig Feb 2, 2012 1:07 PMAfter much discussions and great help I finally got the working FLV component.
Here is my entire code from the label with an FLV component.
import fl.video.VideoProgressEvent;
stop();
close_btn.addEventListener(MouseEvent.CLICK, onClick_GoBackToHowTo2);
function onClick_GoBackToHowTo2(event:MouseEvent) :void {
gotoAndPlay("howto");
}
SWF_flv2.addEventListener(Event.REMOVED_FROM_STAGE,stopF2);
function stopF2(e:Event):void{
SWF_flv2.stop();
SWF_flv2.closeVideoPlayer(1); // actually, you can execute this after the stream completes, too so there's no need to check.
}
play_btn.addEventListener(MouseEvent.CLICK, onClick_Play);
function onClick_Play(event:MouseEvent) :void {
SWF_flv2.play();
}
SWF_flv2.addEventListener(VideoProgressEvent.PROGRESS,progressF);
function progressF(e:VideoProgressEvent):void{
if(e.bytesLoaded == e.bytesTotal){
trace(e.bytesLoaded,e.bytesTotal);
SWF_flv2.play();
}
}
SWF_flv2.activeVideoPlayerIndex=1; //this assigns the player index
SWF_flv2.visibleVideoPlayerIndex=1; //this assigns the player index
SWF_flv2.source = sourceVar; //source must come after assigning the index/s
SWF_flv2.play();
SWF_flv2.stop();
Somehow the video doesn't play automatically eventhough the "autoPlay=true" in the components inspector oprtions.
I would like to find out if there is any specific line of code which should make the video play automatically in addition to:
SWF_flv2.addEventListener(VideoProgressEvent.PROGRESS,progressF);
function progressF(e:VideoProgressEvent):void{
if(e.bytesLoaded == e.bytesTotal){
trace(e.bytesLoaded,e.bytesTotal);
SWF_flv2.play();
}
}
Is there something in the code I messed up and this set up does not function properly?
I also wanted to make play button. Kind of this huge one in the middle of the screen as users used to see on YouTube.
Here is the code for it which seems to work:
play_btn.addEventListener(MouseEvent.CLICK, onClick_Play);
function onClick_Play(event:MouseEvent) :void {
SWF_flv2.play();
}
The problem is it doesn't dissapear once the video plays. How shoudl it be done, the whole video has to go to another frame with no play_btn on it or there is a code which can make it fade away?



