Client-Side Communication ActionScript > NetStream.time |
![]() ![]() ![]() |
NetStream.time
Availability
![]() |
Flash Player 6. |
![]() |
Flash Communication Server MX. |
Usage
myStream
.time
Description
Read-only property; 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(
cameraObj)
or NetStream.attachAudio(
microphoneObj)
, 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.
myStream.attachVideo(cameraObj); myStream.publish("SomeData", "live"); //After 10 seconds, myStream.time = 10 // You then stop sending data over the stream myStream.attachVideo(false); // Later you start sending data over the same stream myStream.attachVideo(cameraObj); // After 10 seconds, myStream.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.
myStream.attachVideo(cameraObj); myStream.publish("SomeData", "live"); //After 10 seconds, myStream.time = 10 //You then stop publishing the stream myStream.publish(false); //10 seconds later, you publish on the same stream myStream.publish("SomeData", "live"); //myStream.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.
myStreamOut.attachVideo(cameraObj); myStreamOut.publish("SomeData", "live"); myStreamIn.play("SomeData"); //After 10 seconds, myStreamIn.time = 10 //You then stop sending data for a while myStreamOut.attachVideo(false); //10 seconds later, you resume sending data over the out stream myStreamOut.attachVideo(cameraObj); //mySteamIn.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
.
//myStream.time starts from 0 myStream.play("live1", -1, 5, true); //5 secounds later, myStream switches from "live1" to "live2" myStream.play("live2", -1, -1, false); //myStream.time continues from 5 //Later you reset the playlist myStream.play("live3", -1, 5, true); //myStream.time resets to 0 again
See also
NetStream.close
, NetStream.play
, NetStream.publish
![]() ![]() ![]() |