NetStream class
111
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()