Watch videos with subtitles in your language, upload your videos, create your own subtitles! Click here to learn more on "how to Dotsub"

Multicast Streaming in Flash Player 10.1

0 (0 Likes / 0 Dislikes)
[ADOBE DEVELOPER CONNECTION] Hello, I'm Tom Krcha. I'm one of the members of Platform Evangelism team. Today, I'm going to show you how you can actually build your own multicasting application. What does it mean? Multicast is the new feature of Flash Player 10.1 and what it actually does is that it enables you to stream over peer-to-peer network, so you can save a lot of money using it. What you have to do is then you have to go to Stratus page and sign up for a Labs beta developer key for Stratus. Once you get it--I've already got it here-- you can go to Flash Builder and actually prepare your application. The thing is that it can look whatever you want, but it should include some video and this is like our views, we're going to work with a camera and video, so just include there some video. You can do it like this. So the next thing you actually have to do is pass this developer key here. Okay, now we are ready to go. So we begin with connecting to the Stratus service, so again, function called connect, and we just create a NetConnection of the type NetConnection. And also, we create stream, which is going to be NetStream type. So one of the applications is going to be broadcaster and the other application is going to be the receiver, so from one application, you will be able to broadcast to the group of participants. So we initialize netConnection = new NetConnection (); We also addEventListener of (NetStatusEvent.NET_STATUS, and we call it netStatus); We create the function handler here private function netStatus(event:NetStatusEvent):void{ and it's going to catch the NetStatusEvent--like that. So once we are here, we can also write this status through field we have already prepared, so writeText(event.info.code); --like that. And finally, we connect to the server, so we just write netConnection.connect( and we include the SERVER+DEVKEY); When we are successfully connected to the server, which we find out here-- switch(event.info.code){ so in case "NetConnection.Connect.Success": we can set up the stream-- setupStream(); So again, what we have to do here is we have to do 2 things. One of them is setting up group specifier, which is an instance and which is actually class, defining what is going to happen in the group, and the second one we have to do is netStream, where we're actually broadcast the stream itself. So we create function setupStream():void{ and as I mentioned, we do this groupspec: instance of group specifier-- yeah, we don't have it here, so what we have to do now is that we go to Multicast--Properties, and Flex Compiler, and to Use a specific version because we are not compiling the application for 10.0, but for 10.1, which is the new player and has the possibility of multicasting. So once the Flex Compiler gets updated, we just--you can already see we have GroupSpecifier here, we create a new instance of it-- GroupSpecifier = new GroupSpecifier( we name it, for instance, like "myGroup/ let's say /multicastOne"); and we also define 2 other things-- so serverChannelEnabled is something which is pretty essential for this, and also multicastEnabled, which enables the multicast or the NetGroup. Then we have to create--we have to use this stream variable, so we create new NetStream and we pass (netConnection, as a first parameter and the second parameter is going to be actually the id of the group, so groupspec.groupspecWIthAuthorizations()); The difference between WithAuthorizations and WithoutAuthorizations is just a matter of the policy of the security you have inside a group. You don't have to care about this to make it work, but maybe in the future it might be very, very useful for you. stream.addEventListener so we can actually see what's going on there and we pass NetStatusEvent: NET_STATUS, netSTATUS); So what we have to do now is we have to initialize the camera object, and once you have this camera object ready, we can show the video which we are actually broadcasting in this broadcast application. And then, we attach this camera to the netStream itself, and then we just publish it. So we create var cam:Camera = Camera.getCamera(); and we don't have to pass anything here, and we also--we only do one thing, which is stream.attachCamera(cam); and also stream.publish and we call it, for instance, "multicast"); --it doesn't matter what you call it, it's just up to you. We're not going to include microphone, even if we can. It's up to you how you just provide all the data for the stream. So the next thing we also have to do here is attach the camera to the video object so we can actually see if everything works-- video.attachCamera(cam); So now we have the broadcast ready. What we have to do now is to actually create receiver for this stream which we are broadcasting to the NetGroup. So what I'm going to do is go to File--New--XML application and create an application called Receiver, which is going to be totally the same as the broadcaster, only with one little change. So just copy and paste the whole code, and we get this camera off, we change publish to play, and we also get this attached camera off, and we actually attach NetStream instead of attaching camera to the video object. And that's the whole change you have to do to have the application for receiving the stream. So now what we can do is launch the broadcaster and see if it works. So now it's connecting, and we can see that the broadcaster is actually sending the stream to the receiver. So that's pretty much it. If you want, you can follow my blog on flashrealtime.com or follow me on twitter at com/tomkrcha. Thank you very much. [ADOBE DEVELOPER CONNECTION]

Video Details

Duration: 8 minutes and 1 second
Country:
Language: English
License: All rights reserved
Genre: None
Views: 141
Posted by: adobetv on Oct 21, 2010

Platform Evangelist Tom Krcha describes how to broadcast video to a group of participants using the peer-to-peer multicast streaming capabilities in Flash Player 10.1.

Caption and Translate

    Sign In/Register for Dotsub to translate this video.