Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/mx"
- applicationComplete="init()">
- <fx:Declarations>
- <!-- Place non-visual elements (e.g., services, value objects) here -->
- </fx:Declarations>
- <fx:Script>
- <![CDATA[
- import mx.core.UIComponent;
- import spark.components.Group;
- private const SERVER:String = "rtmfp://p2p.rtmfp.net/";
- private const DEVKEY:String = "28b1da3b8daae5bf1d25ad63-9f8aad86e65a";
- private var video:Video;
- private var nc:NetConnection;
- private var stream:NetStream;
- private function init():void{
- video = new Video(320,240);
- video.x = 10;
- video.y = 10;
- var uic:UIComponent = new UIComponent();
- uic.addChild(video);
- addElement(uic);
- nc = new NetConnection();
- nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
- nc.connect(SERVER, DEVKEY);
- }
- private function netStatus(event:NetStatusEvent):void{
- writeText(event.info.code);
- switch(event.info.code){
- case "NetConnection.Connect.Success":
- setupStream();
- break;
- }
- }
- private function setupStream():void{
- var groupspec:GroupSpecifier = new GroupSpecifier("group/demo1");
- groupspec.serverChannelEnabled = true;
- groupspec.multicastEnabled = true;
- stream = new NetStream(nc, groupspec.groupspecWithAuthorizations());
- stream.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
- var cam:Camera = Camera.getCamera();
- cam.setQuality(0, 100);
- video.attachCamera(cam);
- stream.attachCamera(cam);
- stream.publish("multicast");
- }
- private function writeText(txt:String):void{
- txtHistory.text += txt+"\n";
- }
- ]]>
- </fx:Script>
- <s:TextArea top="10" bottom="10" id="txtHistory" width="252" right="10"/>
- </s:Application>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement