actionscript 3 - Can't display video coming in from NetStream properly -
i starting work flex , netstream video calls. able read bit netstreams , streaming , wrote code camera , publish stream in video display below in view though pass through methods without error, display not showing don't know what's going on. here did.
<?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" applicationdpi="160" creationcomplete="start();"> <fx:script> import flash.media.camera; import flash.media.video; import flash.net.netconnection; import flash.net.objectencoding; import flash.events.asyncerrorevent; import flash.events.netstatusevent; import flash.net.netstream; import mx.graphics.imagesnapshot; import mx.graphics.codec.jpegencoder; public var camera:camera; var video:video; public var myvideo:video; private var nc:netconnection; private var rtmpf:string="rtmfp://p2p.rtmfp.net/61c33c80be7022350a0dea3d-960194f988ba/"; private const devkey:string = "61c33c80be7022350a0dea3d-960194f988ba"; public var in_ns:netstream; public var out_ns:netstream; public function start():void{ trace("started start function"); nc=new netconnection(); nc.objectencoding = objectencoding.amf0; nc.client=this; nc.addeventlistener(netstatusevent.net_status, netstatushandler); nc.connect(rtmpf); } public function netstatushandler(event:netstatusevent):void{ switch(event.info.code){ case "netconnection.connect.success": trace("received status"); initstart(); default: trace( event.info.code); } } public function initstart():void{ trace("started initstart function"); initnetstream(); initmyvideo(); publish(); playit(); } public function initnetstream():void{ trace("started initnetstream start function"); out_ns=new netstream(nc); out_ns.client=this; in_ns=new netstream(nc); in_ns.client=this; } public function publish():void{ trace("started publish function"); camera=camera.getcamera(); out_ns.attachcamera(camera); out_ns.publish("me", "live"); } public function startcamera(mutecam:boolean=false):void{ if(!video) video = new video(); trace("started startcamera function"); camera=camera.getcamera(); if(mutecam){ video.attachcamera(camera); //out_ns.attachcamera(camera); //out_ns.publish("me", "live"); vidholder.addchild(video); }else{ video.attachcamera(null); if(contains(video)) vidholder.removechild(video); //camera=null; } } public function initmyvideo():void { trace("started initmyvideo function"); myvideo = new video(230,160); myvideo.x = 10; myvideo.width = 230; myvideo.height = 160; myvideo.y = 30; // myvid.addchild(myvideo); } public function playit():void{ trace("started play function"); myvideo.attachnetstream(in_ns); in_ns.play("me"); myvid.addchild(myvideo); } public function stopcamera():void{ vidholder.removechild(video); } </fx:script> <fx:declarations> <!-- place non-visual elements (e.g., services, value objects) here --> </fx:declarations> <s:button x="116" y="28" label="start" click="startcamera(true)"/> <s:videodisplay id="vidholder" x="31" y="87" width="200" height="100" /> <s:videodisplay id="myvid" x="31" y="250"/> <s:button id="stop" x="208" y="28" label="stop" click="startcamera(false)"/> </s:application>
these reasons stopping displaying stream.
are testing on same browser using same webcam device driver ?
possibility not able see maybe since driver being used. virtual webcam driver website manycam , test out. application work.
Comments
Post a Comment