Publishing the webcam in the Internet with FlashCom/Flash Media Server

We know as to connect and to know if our connection perfectly this working, we will see then as to publish ours they cam for the Internet .

Initiating with the call of they webcam:

ActionScript

  1. var teste_cam:Camera = Camera.get();
  2. aovivo.attachVideo(teste_cam);

We go to modify ours codigo, the connection now will be inside of a function: Inside of the function doConnect we will initiate conexao with the FlashCom server

ActionScript

  1. function doConnect() {
  2.     client_nc = new NetConnection();
  3.     client_nc.onStatus = function(info) {
  4.         trace("Level: "+info.level+"   Code: "+info.code);
  5.         txt_status.text = "Level: "+info.level+"   Code: "+info.code;
  6.     };
  7.     //client_nc.connect("rtmp://dominio");
  8.     client_nc.connect("rtmp:/cam");
  9. }

Made this, we will initiate another function to publish the images of cam for the FlashCom

ActionScript

  1. function publishMe() {
  2.     out_ns = new NetStream(_root.client_nc);
  3.     out_ns.attachVideo(teste_cam);
  4.     out_ns.publish("myTestStream");
  5. }

Finishing with the function that dara play to visualize cam it way stream:

ActionScript

  1. function playMe() {
  2.     in_ns = new NetStream(_root.client_nc);
  3.     Published_video.attachVideo(in_ns);
  4.     in_ns.play("myTestStream");
  5. }

Now it is enough to call each function:

ActionScript

  1. // Connect to the server
  2. doConnect();
  3. // Publish the live stream
  4. publishMe();
  5. // Play back the stream from the server
  6. playMe();

the code:

ActionScript

  1. var teste_cam:Camera = Camera.get();
  2. aovivo.attachVideo(teste_cam);
  3. /////////////////
  4. function doConnect() {
  5.     client_nc = new NetConnection();
  6.     client_nc.onStatus = function(info) {
  7.         trace("Level: "+info.level+"   Code: "+info.code);
  8.         txt_status.text = "Level: "+info.level+"   Code: "+info.code;
  9.     };
  10.     //client_nc.connect("rtmp://dominio");
  11.     client_nc.connect("rtmp:/cam");
  12. }
  13. function publishMe() {
  14.     out_ns = new NetStream(_root.client_nc);
  15.     out_ns.attachVideo(teste_cam);
  16.     out_ns.publish("myTestStream");
  17. }
  18. function playMe() {
  19.     in_ns = new NetStream(_root.client_nc);
  20.     Published_video.attachVideo(in_ns);
  21.     in_ns.play("myTestStream");
  22. }
  23. // Connect to the server
  24. doConnect();
  25. // Publish the live stream
  26. publishMe();
  27. // Play back the stream from the server
  28. playMe();

Remembering that it was created two movieclips of the video type with the respective names of instances “aovivo�? and “Published_video�?. Swf publishes its to see the result.
This example this example it is in help of the FlashCom.

view app

Flash Media Server Developer Center
http://www.macromedia.com/devnet/flashmediaserver/

FlashComGuru
http://www.flashcomguru.com/

FlashCom.com.br
http://www.flashcom.com.br/

Flash Media Server Fun
http://www.fczone.com/

Was this article helpful? feel free to make a donation and help keep the blog in the air

Leave a Reply