A simple method for getting a video
Last Update:2018-12-07
Source: Internet
Author: User
<? XML version = "1.0" encoding = "UTF-8"?> <! --/////////////////////////////////////// //////////////////////////////////////// //// Copyright (c) 2007 royllik. // common video components in the local and remote states. Code No need to modify ///////////////////////////////////// //////////////////////////////////////// //// --> <mx: panel xmlns: MX = "http://www.adobe.com/2006/mxml" stylename = "opaquepanel" layout = "absolute" Title = "{thistitle}" horizontalscrollpolicy = "off" verticalscrollpolicy = "off"> <mx: SCRIPT> <! [CDATA [import flash. External. externalinterface; import MX. Controls. Alert; import MX. Core. uicomponent; import MX. Managers. popupmanager; Import flash. media. *; import avchat. chatroom. utils. modellocator; import avchat. chatroom. UI. event. customevent; private VAR model: modellocator = modellocator. getinstance (); [Bindable] public var thistitle: string; Public var recivestream: string; private var camera: Camera; private var mic: microphone; private var outns: netstream; private var inns: netstream; private var video: Video; private var videoholder: uicomponent; protected override function createchildren (): void {super. createchildren (); This. titlebar. addeventlistener (mouseevent. mouse_down, ondown); this. titlebar. addeventlistener (mouseevent. mouse_up, onup);} private function ondown (EVT: Event): void {This. startdrag ();} private function onup (EVT: Event): void {This. stopdrag ();} // disconnect the streaming media and delete videoholder public function stopav (): void {If (outns) {// outns. pause (); outns. close (); // alert. show ("disabled" + outns);} If (INNS) {// inns. pause (); inns. close (); // alert. show ("disabled" + INNS);} If (video) video. clear (); this. removeallchildren (); // This. removechild (videoholder); thistitle = "";} // set the private function setmic (): void {mic. gain = 70; mic. rate = 11; mic. setuseechosuppression (true); mic. setsilencelevels (5, 1000); // mic. setloopback (false);} // sets the camera private function setcam (): void {Camera. setkeyframeinterval (30); camera. setmode (320,240, 25, true); camera. setquality (0, 85); // camera. setloopback (true);} // push your own streaming media public function publishav (recordorlive: String, width: int, height: INT): void {// send a video, the video name is the sender's ID + _ + name of the current room var streamname: String = model. myself. userid + "_" + model. currentroom; // trace ("streamname:" + streamname); If (outns) outns. close (); outns = new netstream (model. fmsserver. NC); outns. client = This; // outns. checkpolicyfile = true; If (camera. names. length> 0) {Camera = camera. getcamera () ;}// trace (CAMERA); If (CAMERA = NULL) {MIC = microphone. getmicrophone (); setmic (); outns. attachaudio (MIC); // you need to determine whether to record it later. // alert. show ("streamname:" + streamname); outns. publish (streamname, recordorlive);} else {MIC = microphone. getmicrophone (); setmic (); setcam (); outns. attachaudio (MIC); outns. attachcamera (CAMERA); // determine whether to record outns as required. publish (streamname, recordorlive); // alert. show ("streamname:" + streamname);} // alert. show ("send by yourself" + streamname); videoholder = new uicomponent (); videoholder. setactualsize (width, height); video = new video (width, height); video. attachcamera (CAMERA); videoholder. addchild (video); this. addchild (videoholder);} // receives a video. The video name is the sender's ID + _ + current room name public function reciveav (width: int, height: INT ): void {// trace (this. recivestream); // var recivestream: String = thisuserid + "_" + model. currentroom; // alert. show ("recivestream:" + recivestream); If (INNS) inns. close (); inns = new netstream (model. fmsserver. NC); // inns. checkpolicyfile = true; inns. play (recivestream); // alert. show ("received" + recivestream); inns. client = This; videoholder = new uicomponent (); videoholder. setactualsize (width, height); video = new video (width, height); video. attachnetstream (INNS); videoholder. addchild (video); this. addchild (videoholder);}]> </MX: SCRIPT> </MX: Panel>