Веб-камера и микрофон должны быть подключены и опознаны ос.
Выводим живое изображение с камеры ... app.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> import mx.controls.Alert; import mx.core.UIComponent; import flash.net.NetConnection; import flash.media.Microphone; private var nc:NetConnection; private var ns:NetStream; private function init():void { // Подключение к медиа-серверу nc = new NetConnection(); nc.client = this; nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus); nc.connect("rtmp:/webcast"); } // Fix for AS3 public function onBWDone():void {} private function onNetStatus(event:NetStatusEvent):void { if (event.info.code != "NetConnection.Connect.Success") { Alert.show(event.info.code); return; } var vContainer:UIComponent = new UIComponent(); var mic:Microphone = Microphone.getMicrophone(); var camWidth:int = 640; var camHeight:int = 480; var cam:Camera = new Camera(); cam = Camera.getCamera(); cam.setMode(camWidth, camHeight, 24); var localvid:Video = new Video(camWidth, camHeight); localvid.attachCamera(cam); vContainer.addChild(localvid); canvasVideoIn.addChild(vContainer); ns = new NetStream(nc); ns.attachCamera(cam); ns.attachAudio(mic); ns.publish("webcast"); } </mx:Script> <mx:Canvas width="700" height="550" y="50" horizontalScrollPolicy="off" verticalScrollPolicy="off" x="20" backgroundColor="0xcccccc" id="canvasVideoIn"> </mx:Canvas> </mx:Application>
Клиентский скрипт client.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> import mx.controls.Alert; import mx.core.UIComponent; import flash.net.NetConnection; private var nc:NetConnection; private var streamIn:NetStream; private var videoIn:Video; private function init():void { nc = new NetConnection(); nc.client = this; nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus); nc.connect("rtmp:/webcast"); } // Fix for AS3 public function onBWDone():void {} private function onNetStatus(event:NetStatusEvent):void { if (event.info.code != "NetConnection.Connect.Success") { //Alert.show(event.info.code ); return; } videoIn = new Video(320, 240); var videoHolder:UIComponent = new UIComponent(); videoHolder.addChild(videoIn); canvasVideoIn.addChild(videoHolder); streamIn = new NetStream(nc); videoIn.attachNetStream(streamIn); streamIn.play("webcast"); } </mx:Script> <mx:Canvas width="320" height="240" y="50" horizontalScrollPolicy="off" verticalScrollPolicy="off" x="20" backgroundColor="0xcccccc" id="canvasVideoIn" /> </mx:Application>
Комментариев нет:
Отправить комментарий