Hi,

With VideoDisplay, you don't need to use onEnterFrame or any external Timer instance. Just subscribe to VideoDisplay's playheadUpdate event and do progress bar logic in event handler.

-abdul

On 8/30/06, Chris Simeone <[EMAIL PROTECTED]> wrote:

Ok, Below is my updated "onEnterFrame()" method that updates a
progressBar component. It works great. Thanks again gang!

Now I'm going to try and get this working using the <mx:videoDisplay>
component. I'm not sure if I can get to its "netStream" object, so any
ideas/recommendations would be helpful and appreciated.

Thanks!
Chris



/////////////////////////////////////////////////////////////
private function onEnterFrame(event:Event):void
{
if(stream == null) return;
if(duration == 0) return;
var loadpct:Number = Math.round(Math.ceil((stream.time/duration)*100));

if(loadpct<=100)
{
bar.setProgress(loadpct,100);
bar.label= "CurrentProgress" + " " + loadpct + "%";
loadpct+=10;
}
if(loadpct>100)
{
loadpct=0;
}
trace("onEnterFrame: Duration: " + duration + " Time: " +
stream.time + " Loaded: " + loadpct + "%");

}

--- In flexcoders@yahoogroups.com, "Chris Simeone" <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I've been trying to create a "Buffering" progress bar for streaming
> FLV (via FMS) with the <mx:videoDisplay> component. But, the
> videoDisplay is not firing "progress" events for some odd reason. So I
> changed my strategy and started using the netStream object.
>
> The video is streaming via FMS, but the netStream "bytesLoaded" and
> "bytesTotal" properties are always zero. Any ideas what I may be doing
> wrong. The code's below.
>
> Also, it would be great if anyone can show how to pull this of with
> the <mx:videoDisplay> component as well!!!
>
> Thanks!
> Chris
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
> layout="vertical" horizontalAlign="left"
> creationComplete="onCreationComplete();">
> <mx:Script>
> <![CDATA[
>
>
//////////////////////////////////////////////////////////////////////////
> import mx.events.VideoEvent;
> import myComponents.*;
> import flash.events.*;
> import flash.net.*;
> import flash.media.Video;
> import mx.controls.*;
> import mx.core.UIComponent;
>
>
//////////////////////////////////////////////////////////////////////////
> private var nc:NetConnection;
> private var stream:NetStream;
> private var fmsUrl:String;
> private var flvName:String;
> private var video:Video;
> private var loaded_interval:Number;
>
>
//////////////////////////////////////////////////////////////////////////
> NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
>
>
//////////////////////////////////////////////////////////////////////////
> public function onCreationComplete():void
> {
> nc = new NetConnection();
> configureListeners(nc);
>
> var videoHolder:UIComponent = new UIComponent();
> videoHolder.setActualSize(700, 525);
>
> video = new Video();
> configureListeners(video);
>
> videoHolder.addChild(video);
> video.x = 0;
> video.y = 0;
>
> fmsUrl = "rtmp://localhost/test_video";
> flvName = "testVideo";
> theBox.addChild(videoHolder);
> nc.connect(fmsUrl);
> }
> /////////////////////////////////////////////////////////////
> private function configureListeners(dispatcher:IEventDispatcher):void
> {
> dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
> onSecurityError);
> dispatcher.addEventListener(AsyncErrorEvent.ASYNC_ERROR,
onAsyncError);
> dispatcher.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
> dispatcher.addEventListener(ProgressEvent.PROGRESS, onProgress);
> dispatcher.addEventListener(Event.ENTER_FRAME, onEnterFrame);
> }
> /////////////////////////////////////////////////////////////
> private function connectStream():void
> {
> if (stream)
> stream.close();
>
> stream = new NetStream(nc);
> configureListeners(stream);
> video.attachNetStream(stream);
> stream.bufferTime = 10;
> stream.play(flvName);
> stream.client = this;
> }
> /////////////////////////////////////////////////////////////
> private function onNetStatus(event:NetStatusEvent):void
> {
> trace("onNetStatus: " + event);
> switch (event.info.code)
> {
> case "NetConnection.Connect.Success":
> trace("NetConnection.Connect.Success");
> connectStream();
> break;
> case "NetConnection.Connect.Failed":
> trace("NetConnection.Connect.Failed");
> break;
> case "NetStream.Buffer.Empty":
> trace("NetStream.Buffer.Empty");
> break;
> case "NetStream.Buffer.Full":
> trace("NetStream.Buffer.Full");
> break;
> case "NetStream.Play.StreamNotFound":
> trace("stream not found: " + flvName);
> break;
> }
> }
> /////////////////////////////////////////////////////////////
> private function onEnterFrame(event:Event):void
> {
> if(stream == null) return;
> var loadpct:Number = stream.bytesLoaded / stream.bytesTotal * 100;
> trace("onEnterFrame: " + event + " Loaded: " + loadpct + "%");
> }
> /////////////////////////////////////////////////////////////
> private function onProgress(event:ProgressEvent):void
> {
> trace("onProgress: " + event);
> }
> /////////////////////////////////////////////////////////////
> private function onSecurityError(event:SecurityErrorEvent):void
> {
> trace("onSecurityError: " + event);
> }
> /////////////////////////////////////////////////////////////
> private function onAsyncError(event:AsyncErrorEvent):void
> {
> trace("onAsyncError: " + event);
> }
> /////////////////////////////////////////////////////////////
> public function onMetaData(info:Object):void
> {
> trace("metadata: duration=" + info.duration + " width=" +
> info.width + " height=" + info.height + " framerate=" + info.framerate);
> }
> /////////////////////////////////////////////////////////////
> public function onCuePoint(info:Object):void
> {
> trace("cuepoint: time=" + info.time + " name=" + info.name + "
> type=" + info.type);
> }
> /////////////////////////////////////////////////////////////
> public function showMessage(msg:String):void
> {
> trace("showMessage: " + msg + "\n");
> }
> /////////////////////////////////////////////////////////////
> ]]>
> </mx:Script>
>
> <mx:HBox id="theBox" borderStyle="solid"></mx:HBox>
> </mx:Application>
>


__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to