VIDEO AND SOUND

One of the most interesting part of work using FlashComm is the use of video and sound streams.It's very easy. Look the figure:

It's possible that you are thinking that: inside an application folder we can have only one Flash movie having the same name of the folder. It's not true. Only the connection needs to be the same. We can have many flash movies and many names.

Our exercice will have 2 Flash movies. The idea is create a TV station. The first movie creates an stream of Video and a stream of audio.

There are another Flash movie. Everybody accessing the page having this movie will see and listen our TV station.

FlashCom has a new group of Communication Components. You can download them, going to the Macromedia site. At our exercices we will use a basic component (is more only a Video-Clip) that is not in the window of components: Embeded Video. You need to open the Library window and click the icon at right. At the popup list, click: New Video.

To the first movie of our application the name will be: out0.fla). The instance name of Embeded Video. will be: Live_video. Create also a "dinamic text" for messages.

The program glued to the frame is:

stop();
client_nc=new netConnection();
client_nc.connect("rtmp://domain-name/video0");//video0 is the folder
client_nc.onStatus = function(info){
 if(info.code=="NetConnection.Connect.Success"){
  _root.msg.text = "The connection was a success!";
 }
 else{
  _root.msg.text = "Application not available now!";
 }
}
// Make outgoing network streams for video and sound: 
vout_ns=new netStream(client_nc);
sout_ns=new netStream(client_nc);
//Publish the streams defining their names
vout_ns.publish("video0");
sout_ns.publish("sound0");
//Attach a microphone
sout_ns.attachAudio(Microphone.get());
//Attach a camera to the stream and to the component	
client_cam=Camera.get();
vout_ns.attachVideo(client_cam);
Live_video.attachVideo(client_cam);

Only this. And you have a TV station!

There are another Flash movie (in0.fla) in the same application, having also the Embeded Video whose instance name will be: Published_video. The program glued to the frame is:

stop();
client_nc=new netConnection();
client_nc.connect("rtmp://domain-name/video0");
client_nc.onStatus=function(info){
 if(info.code=="NetConnection.Connect.Success"){
  _root.msg.text = "The connection was a success!";
 }
 else{
  root.msg.text = "Application not available now!";
 }
}
// Make  new, incoming network streams:
vin_ns=new netStream(client_nc);
sin_ns=new netStream(client_nc);
//Attach the incoming stream to the 'Published_video' 
Published_video.attachVideo(vin_ns);
//Play video and sound
vin_ns.play("video0");
sin_ns.play("sound0");

When an internaut open the page having this Flash movie, he will receive the transmission of the TV station.

Our demo has, in this page, the Flash movie to create the station. And you can open a viewer clicking the button:

THIS DEMO USE OUR FLASHCOMM SERVER. IT'S AVAILABLE ONLY A FEW HOURS EACH DAY.SORRY IF IT'S NOT AVAILABLE NOW.




PREVIOUS LESSON NEXT LESSON
T. CONTENTS HOMEPAGE