User Guide
642 Chapter 2: ActionScript Language Reference
NetStream.time
Availability
Flash Player 7.
Note: This property is also supported in Flash Player 6 when used with Flash Communication Server.
For more information, see the Flash Communication Server documentation.
Usage
my_ns.time:Number
Description
Read-only property; the position of the playhead, in seconds.
Example
The following example displays the current position of the playhead in a dynamically created text
field called
time_txt. Select New Video from the Library options menu to create a video object
instance, and give it an instance name
my_video. Add the following ActionScript to your FLA or
AS file:
var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
my_video.attachVideo(stream_ns);
stream_ns.play("video1.flv");
//
stream_ns.onStatus = function(infoObject:Object) {
statusCode_txt.text = infoObject.code;
};
this.createTextField("time_txt", this.getNextHighestDepth(), 10, 10, 100, 22);
time_txt.text = "LOADING";
var time_interval:Number = setInterval(checkTime, 500, stream_ns);
function checkTime(my_ns:NetStream) {
var ns_seconds:Number = my_ns.time;
var minutes:Number = Math.floor(ns_seconds/60);
var seconds = Math.floor(ns_seconds%60);
if (seconds<10) {
seconds = "0"+seconds;
}
time_txt.text = minutes+":"+seconds;
}
See also
NetStream.bufferLength, NetStream.bytesLoaded