View comments | RSS feed

NetStream.time

Availability

Usage

public time : Number [read-only]

Description

Property (read-only); for a subscriber stream, the number of seconds the stream has been playing; for a publishing stream, the number of seconds the stream has been publishing. This number is accurate to the thousandths decimal place; multiply by 1000 to get the number of milliseconds the stream has been playing.

When you are publishing a stream, this property stops incrementing when you stop sending data over the stream by calling NetStream.attachVideo(false) or NetStream.attachAudio(false). When you resume publishing by calling NetStream.attachVideo(active_cam) or NetStream.attachAudio(active_mic), the time property continues incrementing from where it left off, plus the time that elapsed while no data was sent. When you stop publishing a stream by calling Netstream.publish(false), the time property stops incrementing and is reset to 0 when you resume publishing the stream.

For a subscribing stream, if the server stops sending data but the stream remains open, this value stops incrementing. When the server begins sending data again, the value of this property continues incrementing from where it left off plus the time that elapsed while no data was sent. The value of this property continues to increment when the stream switches from one playlist element to another. This property is set to 0 when NetStream.play is called with flushPlaylists set to true, or when NetStream.close is called.

Example

The following example shows how, while you are publishing a stream, NetStream.time continues to increment even while no data is being sent over a stream:

my_ns.attachVideo(active_cam);
my_ns.publish("SomeData", "live");
//After 10 seconds, my_ns.time = 10.

// You then stop sending data over the stream.
my_ns.attachVideo(false);

// Later you start sending data over the same stream.
my_ns.attachVideo(active_cam);
// After 10 seconds, my_ns.time = 20.

The following example shows how NetStream.time is reset to 0 when you stop publishing a stream for a while and then start publishing the same stream:

my_ns.attachVideo(active_cam);
my_ns.publish("SomeData", "live");
//After 10 seconds, my_ns.time = 10.

//You then stop publishing the stream.
my_ns.publish(false);

//10 seconds later, you publish on the same stream.
my_ns.publish("SomeData", "live");
//my_ns.time resets to 0.

The following example shows how, while you are subscribing to a stream, NetStream.time continues to increment even while no data is being sent over the stream:

publish_ns.attachVideo(active_cam);
publish_ns.publish("SomeData", "live");
play_ns.play("SomeData");
//After 10 seconds, play_ns.time = 10.

//You then stop sending data for a while.
publish_ns.attachVideo(false);

//10 seconds later, you resume sending data over the publishing stream.
publish_ns.attachVideo(active_cam);
//play_ns.time continues with 20.

The following example shows how, when subscribing to a stream, you can control whether NetStream.time is reset to 0 between items in a playlist by setting the NetStream.play method's flushPlaylists parameter to true or false:

//my_ns.time starts from 0.
my_ns.play("live1", -1, 5, true);

//5 secounds later, my_ns switches from "live1" to "live2".
my_ns.play("live2", -1, -1, false);
//my_ns.time continues from 5.

//Later you reset the playlist.
my_ns.play("live3", -1, 5, true);
//my_ns.time resets to 0 again.

See also

NetStream.close(), NetStream.play(), NetStream.publish()


Comments


Fuzyylogic said on Aug 31, 2007 at 12:23 AM :
The NetStream.time when finished doesn't match with Stream.length. Any idea how to fix this.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/fms/2/docs/00000595.html