Broadcasting stops itself in the bigger .fla?? :S
Hi!
I want to broadcast my webcam.
I have 2 fla's one is nearly empty and the other one is very big.
the bigger one has many movieclips other .as classes but it doesn't run them,
the code running in both fla's are exacty same!
I watch these webcams from another receiver flash.
When i use the bigger one stops broadcasting after a few seconds,
but the smaller fla's broadcast is received all the time???
What should i do to fix the bigger fla??
The broadcastion code is simple
| Header 1 |
|---|
| package { import flash.display.Sprite; import flash.events.*; import flash.media.*; import flash.net.*; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.utils.Timer; import flash.events.TimerEvent; import flash.events.StatusEvent; import flash.events.MouseEvent; import flash.system.SecurityPanel; import flash.system.Security; public class streamer extends Sprite { var vid:Video; private var cam:Camera; private var t:Timer = new Timer(1000); private var my_nc:NetConnection = new NetConnection(); public function streamer() { this.stage.addEventListener(Event.ENTER_FRAME, myEnterFrame); cam = Camera.getCamera(); if(!cam) { myTextField.text = "No camera is installed."; } else if (cam.muted) { myTextField.text = "To enable the use of the camera,\n" + "please click on this text field.\n" + "Grant access to your camera."; myTextField.addEventListener(MouseEvent.CLICK, clickHandler); }else { myTextField.text = "Connecting"; connectCamera(); goLive(); } addChild(myTextField); t.addEventListener(TimerEvent.TIMER, timerHandler); } function myEnterFrame(evt:Event) { this.setChildIndex(myTextField, this.numChildren - 1); this.setChildIndex(vid, this.numChildren - 1); } private function clickHandler(e:MouseEvent):void { Security.showSettings(SecurityPanel.PRIVACY); cam.addEventListener(StatusEvent.STATUS, statusHandler); myTextField.removeEventListener(MouseEvent.CLICK, clickHandler); } private function statusHandler(event:StatusEvent):void { if (event.code == "Camera.Unmuted") { connectCamera(); cam.removeEventListener(StatusEvent.STATUS, statusHandler); } } private function connectCamera():void { vid = new Video(cam.width, cam.height); vid.x = 0; vid.y = 0; vid.attachCamera(cam); addChild(vid); t.start(); } private function timerHandler(event:TimerEvent):void { myTextField.text = "fps: " + Math.round(cam.currentFPS); /* myTextField.appendText("bandwidth: " + cam.bandwidth + "\n"); myTextField.appendText("currentFPS: " + Math.round(cam.currentFPS) + "\n"); myTextField.appendText("fps: " + cam.fps + "\n"); myTextField.appendText("keyFrameInterval: " + cam.keyFrameInterval + "\n"); */ } private function goLive() { my_nc = new NetConnection(); my_nc.client = this; my_nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); my_nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); my_nc.connect("rtmp://localhost/live/livestream"); } private function startLive() { // capture my camera and publish "my_cam" to server var publisher:NetStream = new NetStream(my_nc); publisher.attachAudio(Microphone.getMicrophone()); publisher.attachCamera(Camera.getCamera()); publisher.publish("livestream", "live"); // opens a stream using the previous connection object // play the published stream "my_cam" var viewer:NetStream = new NetStream(my_nc); viewer.play("my_cam"); } public function onBWDone():void { } private function netStatusHandler(event:NetStatusEvent):void { switch (event.info.code) { case "NetConnection.Connect.Success": startLive(); break; case "NetStream.Play.StreamNotFound": trace("Stream not found"); break; } } private function securityErrorHandler(event:SecurityErrorEvent):void { trace("securityErrorHandler: " + event); } } } |
