I want to add the following script in my action script for redirecting to first frame after the external video finish,
But I'm not sure how to customize the code that suitable for my sction script.
This is the code I want to add with my AS :
ns.onStatus = function(info:Object)
{
if(info.code == 'NetStream.Play.Stop')
{
gotoAndPlay(2);
}
}
The following one is the original code now I'm using to play external video files. I need to customize the above code that should be usable for the below one.
function checkTime(flv)
{
var _loc2 = flv.playheadTime;
var _loc3 = Math.floor(_loc2 / 60);
var _loc1 = Math.floor(_loc2 % 60);
if (_loc1 < 10)
{
_loc1 = "0" + _loc1;
} // end if
current_time.text = _loc3 + ":" + _loc1;
} // End of the function
flv.pauseButton = pause_btn;
flv.playButton = play_btn;
flv.FLVPlayback.align = center;
var time_interval = setInterval(checkTime, 500, flv);
ffwd_btn.onRelease = function ()
{
flv.seek(flv.playheadTime + 2);
};
rewind_btn.onRelease = function ()
{
flv.seek(flv.playheadTime - 5);
};
mute_btn.onRelease = function ()
{
if (videoSound.getVolume() == 0)
{
videoSound.start();
开发者_高级运维 videoSound.setVolume(volLevel);
}
else
{
volLevel = _root.videoSound.getVolume();
videoSound.setVolume(0);
videoSound.stop();
} // end else if
};
var videoSound = new Sound(this);
videoSound.setVolume(100);
flv.contentPath = flvurl;
fl.video.FLVPlayback.align = center;
Can anyone help me?
since you are using AS2, and the complete
event firing is inconsistent with the FLVPlayback component in AS2 AND you are already polling with setInterval
, just compare the video duration
to the playheadTime
in you checkTime()
function like so:
function checkTime()
{
// you other stuff here....
if( flv.metadata && flv.metadata.duration > 0)
{
var prog:Number = Math.round((flv.playheadTime/flv.metadata.duration)*100);
if( prog == 100 )
{
//clean up your interval
clearInterval(time_interval);
// do 'end of video' stuff
gotoAndPlay(2);
}
}
}
note that the duration
is nested inside the metadata
property of the FLVPlayback
instance. It's not available until enough of the flv file has loaded, but since you are polling with your interval, it will be there when you need it.
should get ya what ya want...
精彩评论