Advertisement
Guest User

Untitled

a guest
Jul 8th, 2014
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
  3.                xmlns:s="library://ns.adobe.com/flex/spark"
  4.                xmlns:mx="library://ns.adobe.com/flex/mx"
  5.                applicationComplete="init()">
  6.    
  7.     <fx:Declarations>
  8.         <!-- Place non-visual elements (e.g., services, value objects) here -->
  9.     </fx:Declarations>
  10.    
  11.     <fx:Script>
  12.         <![CDATA[
  13.             import mx.core.UIComponent;
  14.             import spark.components.Group;
  15.            
  16.             private const SERVER:String = "rtmfp://p2p.rtmfp.net/";
  17.             private const DEVKEY:String = "28b1da3b8daae5bf1d25ad63-9f8aad86e65a";
  18.            
  19.             private var video:Video;
  20.            
  21.             private var nc:NetConnection;
  22.             private var stream:NetStream;
  23.            
  24.             private function init():void{
  25.                 video = new Video(320,240);
  26.                 video.x = 10;
  27.                 video.y = 10;
  28.                
  29.                 var uic:UIComponent = new UIComponent();
  30.                 uic.addChild(video);
  31.                
  32.                 addElement(uic);
  33.                
  34.                 nc = new NetConnection();
  35.                 nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
  36.                 nc.connect(SERVER, DEVKEY);
  37.             }
  38.            
  39.             private function netStatus(event:NetStatusEvent):void{
  40.                 writeText(event.info.code);
  41.                
  42.                 switch(event.info.code){
  43.                     case "NetConnection.Connect.Success":
  44.                         setupStream();
  45.                         break;
  46.                 }
  47.                
  48.             }
  49.            
  50.             private function setupStream():void{
  51.                 var groupspec:GroupSpecifier = new GroupSpecifier("group/demo1");
  52.                 groupspec.serverChannelEnabled = true;
  53.                 groupspec.multicastEnabled = true;
  54.                
  55.                 stream = new NetStream(nc, groupspec.groupspecWithAuthorizations());
  56.                 stream.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
  57.                
  58.                 var cam:Camera = Camera.getCamera();
  59.                 cam.setQuality(0, 100);
  60.                 video.attachCamera(cam);
  61.                
  62.                 stream.attachCamera(cam);
  63.                 stream.publish("multicast");
  64.             }
  65.            
  66.             private function writeText(txt:String):void{
  67.                 txtHistory.text += txt+"\n";
  68.             }
  69.            
  70.         ]]>
  71.     </fx:Script>
  72.    
  73.     <s:TextArea top="10" bottom="10" id="txtHistory" width="252" right="10"/>
  74. </s:Application>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement