View comments | RSS feed

NetStream.pause()

Availability

Usage

public pause( [ flag : Boolean] ) : Void

Parameters

flag Optional: a Boolean value specifying whether to pause play (true) or resume play (false). If you omit this parameter, NetStream.pause() acts as a toggle: the first time it is called on a specified stream, it pauses play, and the next time it is called, it resumes play.

Returns

Nothing.

Description

Method; pauses or resumes playback of a stream. This method is available only to clients subscribed to the specified stream, not to the stream's publisher.

The first time you call this method on a given playlist (without sending a parameter), it pauses the playlist; the next time, it resumes play. You might want to attach this method to a button that the user presses to pause or resume playback.

Example

The following examples illustrate some uses of this method.

my_ns.pause(); // pauses play first time issued
my_ns.pause(); // resumes play
my_ns.pause(false); // no effect, play continues
my_ns.pause(); // pauses play

In the following example, suppose you have a playlist of three recorded streams.

var my_nc:NetConnection = new NetConnection();
my_nc.connect("rtmp://localhost/appName/appInstance");

// Create a NetStream for playing back in a Video object named my_video.
var my_ns:NetStream = new NetStream(my_nc);
my_video.attachVideo(my_ns);

// to play record1
my_ns.play("record1", 0, -1, false);

// to play record2
my_ns.play("record2", 0, -1, false);

// to play record3
my_ns.play("record3", 0, -1, false);

// You click a button to pause while record2 is playing.
my_ns.pause(); 

// Later, you want to resume the play.
my_ns.pause();

// Later, you want to start a new playlist.

// to play record4
my_ns.play("record4", 0, -1, true);

// to play record5
my_ns.play("record5", 0, -1, false);

// to play record6
my_ns.play("record6", 0, -1, false);

See also

NetStream.close(), NetStream.play()


Comments


No screen name said on Oct 24, 2006 at 2:50 AM :
I would like to know why if I put in pause a recorded stream, the buffer is empty.

my_video.attachVideo(stream_ns);
stream_ns.setBufferTime(15);
stream_ns.onStatus = function(infoObject:Object) {
statusCode_txt.text = infoObject.code;
if (infoObject.code == "NetStream.Buffer.Full") {
trace("Here the buffer is full = "+stream_ns.bufferLength);
stream_ns.pause(true);
trace("Here the buffer is empty = "+stream_ns.bufferLength);
}
};

Is it true ? Thanks.

Paolo
No screen name said on Mar 16, 2007 at 8:10 AM :
I'm having the same problem. I would like to pause the stream with out losing the buffered video.
Anyone have any ideas
No screen name said on Jan 28, 2008 at 3:14 PM :
Starting with Flash Player 9.0.115.0 the player will retain the buffer on pause.

 

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/00000587.html