
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
77
Example
ns = new NetStream(nc);
ns.onStatus = function(info){
if (info.code == "NetStream.Publish.Start"){
trace("It is now publishing");
}
ns.publish("foo", "live");
}
NetStream.publish()
ns.publish(name, howToPublish)
Publishes a stream to a remote server. If the stream has been published by another client, the publish() call can fail
when it reaches the remote server. Check the status in the
NetStream.onStatus() handler to make sure that the
publisher has been accepted.
Availability
Flash Media Interactive Server 3 and Flash Media Development Server 3
Parameters
name A string identifying the stream to publish. If you pass false, the stream stops publishing.
howToPublish A string specifying how to publish the stream. Valid values are "record", "append", and "live".
The default value is
"live". This parameter is optional.
If you pass
"record", the live data is recorded to a file called name.flv. The file is stored on the remote server
associated with the NetConnection object. If the file already exists, it is overwritten.
If you pass
"append", the live data is appended to a file called name.flv. The file is stored on the remote server
associated with the NetConnection object. If a file called name.flv is not found, it is created.
If you omit this parameter or pass
"live", live data is published but not recorded. If a file called name.flv exists on
the remote server, it is deleted.
Note: If name.flv is read-only, live data is published and name.flv is not deleted.
Example
application.onPublish = function(client, myStream){
nc = new NetConnection();
nc.connect("rtmp://example.com/myApp");
ns = new NetStream(nc);
Code property Level property Description
NetStream.Publish.Start
status
An attempt to publish was successful.
NetStream.Publish.BadName
error
An attempt was made to publish to a stream that is already being
published by someone else.
NetStream.Unpublish.Success
status
An attempt to stop publishing a stream was successful.
NetStream.Record.Start
status
Recording was started.
NetStream.Record.Stop status
Recording was stopped.
NetStream.Record.NoAccess
status
An attempt was made to record a read-only stream.
NetStream.Record.Failed
error
An attempt to record a stream failed.
Commenti su questo manuale