kamaitachi example live_streaming typester forked:2favorite:0lines:83license : MIT License modified : 2010-10-16 03:41:29 Embed Tweet <?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()"> <mx:Script><![CDATA[ import flash.net.*; import flash.events.*; import flash.media.*; private var nc:NetConnection; private var ns:NetStream; private function status_handler(event:NetStatusEvent):void { switch (event.info.code) { case "NetConnection.Connect.Success": setStatus("Connected."); break; default: setStatus(event.info.code); } } private function setStatus(text:String):void { status.text = text; } private function connectConn():void { var host_name:String = host.text; if (!host_name) return; nc = new NetConnection(); nc.addEventListener(NetStatusEvent.NET_STATUS, status_handler); nc.objectEncoding = ObjectEncoding.AMF0; nc.client = this; nc.connect(host_name); } private function closeConn():void { nc.close(); } private function publishNs():void { var channel_name:String = input.text; if (!channel_name) return; ns = new NetStream(nc); ns.addEventListener(NetStatusEvent.NET_STATUS, status_handler); var camera:Camera = Camera.getCamera(); if (!camera) { setStatus("No camera found"); return; } var mic:Microphone = Microphone.getMicrophone(); if (!mic) { setStatus("No mic found"); return; } // set quality camera.setMode(320, 240, 30); camera.setQuality(0, 80); mic.setSilenceLevel(0); mic.rate = 44; video.attachCamera(camera); ns.attachCamera(camera); ns.attachAudio(mic); ns.publish(channel_name, "live"); } private function unpublishNs():void { ns.close(); } public function onMessage(message:String):void { message_label.text = message; } ]]></mx:Script> <mx:Panel title="simple live publish example" paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"> <mx:HBox> <mx:Label text="Host:"/> <mx:TextInput id="host" width="120" text="rtmp://127.0.0.1/stream/live" /> <mx:Button id="connectConn_button" label="connect" click="connectConn()" enabled="true"/> <mx:Button id="closeConn_button" label="close" click="closeConn()" enabled="true"/> </mx:HBox> <mx:HBox> <mx:Label text="Name:"/> <mx:TextInput id="input" width="120"/> <mx:Button id="publish_button" label="publish" click="publishNs()"/> <mx:Button id="unpublish_button" label="unpublish" click="unpublishNs()"/> </mx:HBox> <mx:VideoDisplay id="video" width="320" height="240" /> <mx:VBox> <mx:Label id="status" text="Connecting..."/> <mx:Label id="message_label" text=""/> </mx:VBox> </mx:Panel> </mx:Application> Code Fullscreen Preview Fullscreen width publish height text sort new page view favorite forked pv112 forked from: kamaitachi exampl.. iranakune forked:0 favorite:2lines:84 (diff:1) pv113 forked from: kamaitachi exampl.. HitomiMagne forked:0 favorite:0lines:83 (diff:10)