MACROMEDIA FLASH COMMUNICATION SERVER MX-SERVER-SIDE COMMUNICATION ACTIONSCRIPT DICTIONARY Spécifications Page 99

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 369
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 98
About Flash Communication Server 21
3 Create a connection function that connects to the Flash Communication Server, displays a
trace message indicating whether the connection was successful, and opens and instance of the
doc_connect application named room_01. Remember, you must specify the Real-Time
Messaging Protocol,
rtmp.
function doConnect() {
client_nc = new netConnection();
client_nc.onStatus = function(info) {
trace("Level: " + info.level + " Code: " + info.code);
}
client_nc.connect("rtmp://localhost/doc_connect/room_01");
}
Note: If your SWF is on the same computer that is running the Flash Communication Server, you can use
rtmp:/doc_connect/test as a shortcut version of rtmp://localhost/doc_connect/test. This usage indicates a
relative path and lets you move the files to a different server without changing the code. Also, remember that if
you aren’t using the Flash MX authoring environment on the computer that is running the Flash Communication
Server, substitute your server URL for “localhost”.
4 Create a function to publish the video by creating a network stream out_ns, attaching the
camera to that stream, and then publishing the stream as
myTestStream.
function publishMe() {
out_ns = new netStream(_root.client_nc);
out_ns.attachVideo(client_cam);
out_ns.publish("myTestStream");
}
Note: The statement out_ns.publish("myTestStream") omits the optional parameter howToPublish.
When this parameter is missing, the server automatically publishes the stream as live (that is, the stream is not
recorded while it is being published).
5 Create a function to play the published stream by creating a second network stream in_ns,
attaching the contents of that stream to the Published_video video object, and then playing
the stream named
myTestStream that is being published by the server.
function playMe() {
in_ns = new netStream(_root.client_nc);
Published_video.attachVideo(in_ns);
in_ns.play("myTestStream");
}
6
Write the commands to call the functions you just created.
// Connect to the server
doConnect();
// Publish the live stream
publishMe();
// Play back the stream from the server
playMe();
7
Save the file.
Vue de la page 98
1 2 ... 94 95 96 97 98 99 100 101 102 103 104 ... 368 369

Commentaires sur ces manuels

Pas de commentaire