all groups > flash (macromedia) > november 2005 >
You're in the

flash (macromedia)

group:

Getting the status of a video?


Re: Getting the status of a video? Sneelock
11/30/2005 4:49:16 PM
flash (macromedia):
Plus very usable code in the help files...

[quoted text, click to view]

Re: Getting the status of a video? Sneelock
11/30/2005 4:58:20 PM
To play back an external FLV file in a Flash document:
1.. Create a new Flash document called playFLV.fla.
2.. In the Library panel (Window > Library), select New Video from the
Library pop-up menu.
3.. In the Video Properties dialog box, name the video symbol and select
Video (ActionScript controlled).
4.. Click OK to create a video object.
5.. Drag the video object from the Library panel to the Stage to create a
video object instance.
6.. With the video object selected on the Stage, type my_video in the
Instance Name text box in the Property inspector (Window > Properties >
Properties).
7.. Select Frame 1 in the Timeline, and open the Actions panel (Window >
Actions).
8.. Type the following code in the Actions panel:
this.createTextField("status_txt", 999, 0, 0, 100, 100);
status_txt.autoSize = "left";
status_txt.multiline = true;
// Create a NetConnection object
var my_nc:NetConnection = new NetConnection();
// Create a local streaming connection
my_nc.connect(null);
// Create a NetStream object and define an onStatus() function
var my_ns:NetStream = new NetStream(my_nc);
my_ns.onStatus = function(infoObject:Object):Void {
status_txt.text += "status (" + this.time + " seconds)\n";
status_txt.text += "\t Level: " + infoObject.level + "\n";
status_txt.text += "\t Code: " + infoObject.code + "\n\n";
};
// Attach the NetStream video feed to the Video object
my_video.attachVideo(my_ns);
// Set the buffer time
my_ns.setBufferTime(5);
// Begin playing the FLV file
my_ns.play("http://www.helpexamples.com/flash/video/clouds.flv");

Getting the status of a video? selfproclaimedgeek
11/30/2005 11:17:44 PM
Is there any way to get the status of either a NetStream or a Video? I need to
know 2 things really: when the NetStream is done downloading, and when the
Video has completly played it's content. I've tried googling it (extensively),
but can't seem to find anything.

Help is greatly appreciated :).
Re: Getting the status of a video? Rothrock
11/30/2005 11:52:08 PM
Not sure what you mean by a NetStream or a Video? I know that there is
documentation for the NetStream class in the Flash help files and it shows
getBytesTotal and getBytesLoaded properties. I'm guessing when they are equal
then it is loaded. There is also an onStatus event which reports on several
different things ? including the stop at the end.

By Video do you mean if you use one of the Media components? If so the help
files have a section which explains everything about the Media components.
There you will find getBytesTotal and getBytesLoaded. The components are a
little different in that they have a complete event.


Re: Getting the status of a video? selfproclaimedgeek
12/1/2005 12:12:00 AM
Oh yes, good point on the NetStream. I shall use that.

For video, I meant a normal video viewer (yea, media). I tried onStatus, but
it never gets called whatsoever. Maybe I'm doing something wrong with that?

Thanks for the reply :)
Re: Getting the status of a video? Rothrock
12/1/2005 12:21:02 AM
There is no onStatus for the media player components. Just a complete event.
There are problems with it however. Certain work flows seem to encode FLVs that
don't have the event. So that could be a problem.

The NetStream is IMHO a better approach to use. There are great tutorials at
gotoAndLearn.com on how to make a video player. (As well as several other
topics.)

Good luck.
AddThis Social Bookmark Button