I’m building a video player and I wanted to know how to use the buffering bar and seek bar found in the flash video components. Does anyone have a tutorial on this? I have a play, pause and stop button but I don’t know how to add the buffering or seek bars.
import caurina.transitions.Tweener;
var fv:String=root.loaderInfo.parameters.vars;
output.appendText(fv + " : " + root.loaderInfo.parameters.vars + "
");//working
var vidSource:String;
//vidSource = "http://www.helpexamples.com/flash/video/caption_video.flv"
vidSource ="http://pegasus.dev.webriverinteractive.com/API/Resource.ashx?ResourceID=16"
//vidSource = root.loaderInfo.parameters.vars
var video:Video;
var connect_nc:NetConnection = new NetConnection();
connect_nc.connect(null);
var stream_ns:NetStream = new NetStream(connect_nc);
stream_ns.client = this;
function netStatusHandler(p_evt:NetStatusEvent):void
{
if(p_evt.info.code == "NetStream.FileStructureInvalid")
{
trace("The MP4's file structure is invalid.");
}
else if(p_evt.info.code == "NetStream.NoSupportedTrackFound")
{
trace("The MP4 doesn't contain any supported tracks");
}
}
stream_ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
video = new Video();
video.width = 640;
video.height = 360;
addChild(video);
video.attachNetStream(stream_ns);
stream_ns.play(vidSource);
//set up video controls
var vidControls:MovieClip = new Controls();
addChildAt(vidControls, 2);
vidControls.x = 4;
vidControls.y = 304;
//hide video controls
vidControls.alpha = 0;
vidControls.buttonMode = true;
vidControls.play_mc.visible = false;
vidControls.play_mc.addEventListener(MouseEvent.MOUSE_DOWN, playVideo, false, 0, true);
vidControls.pause_mc.addEventListener(MouseEvent.MOUSE_DOWN, pauseVideo, false, 0, true);
vidControls.stop_mc.addEventListener(MouseEvent.MOUSE_DOWN, stopVideo, false, 0, true);
vidControls.addEventListener(MouseEvent.MOUSE_OVER, showControls, false, 0, true);
vidControls.addEventListener(MouseEvent.MOUSE_OUT, hideControls, false, 0, true);
function showControls(event:MouseEvent):void {
//vidControls.alpha = 100;
Tweener.addTween(vidControls, {alpha:1, time:2});
}
function hideControls(event:MouseEvent):void {
//vidControls.alpha = 0;
Tweener.addTween(vidControls, {alpha:0, time:2});
}
/**/
//Play Button Function(simply set to resume if paused)
function playVideo(event:MouseEvent):void {
stream_ns.resume();
vidControls.play_mc.visible = false;
vidControls.pause_mc.visible = true;
}
//Pause Button function
function pauseVideo(event:MouseEvent):void {
stream_ns.pause();
vidControls.play_mc.visible = true;
vidControls.pause_mc.visible = false;
}
// Pause the stream and move the playhead back to the beginning of the stream.
function stopVideo(event:MouseEvent):void {
stream_ns.pause();
stream_ns.seek(0);
vidControls.pause_mc.visible = false;
vidControls.play_mc.visible = true;
}