Develop simple video live features with Flex and Red5

Source: Internet
Author: User
Tags addchild cdata

Flex is an efficient, free, open source framework for building expressive Web applications that leverage Adobe Flash player and Adobe AIR for cross-browser, desktop, and operating systems. Although flex applications can only be built using the Flex framework, Adobe Flash Builder™ (formerly known as Adobe Flex builder™) software can accelerate development with features such as smart encoding, interactive traversal debugging, and visual design user interface layouts. RIA created with Flex can run in a browser with an Adobe Flash Player plugin, or on a cross-operating system of Adobe Air, which runs consistently across all major browsers and operating systems. Local data and system resources can be accessed by leveraging Adobeair,flex applications. Flex interprets. mxml files through a non-flash path, such as Java or. NET, and generates the appropriate. swf file. Flex's component is similar to Flash's component, but has improved. At present Macromedia Company has been acquired by Adobe Corporation. ADOBE2013 donated flex to Apache on January 15 and released Apache Flex4.8. the main differences between Flex and Flash: 1, Flex focuses on the application software, game development, flash more focus on the Web site to display the effect. 2, Flex generated SWF file is large, not conducive to network transmission, Flash generated SWF file is small, suitable for display on the site. Classic Applications1. EBay 2. Nasdaq Stock Market Company

Red5 's main function is similar to the Macromedia Company's FMS, which provides a Java-based, open source streaming media server based on flash streaming services. It is written in the Java language and uses rtmp as the streaming media transport protocol, which is fully compatible with FMS. It has streaming flv, MP3 files, real-time recording client stream for FLV files, shared objects, real-time video playback, remoting and other functions. After replacing the FMS with RED5, the client does not need to change to function properly.

Instance:

1. Server-side applicationadapter: Examples are as follows:

 Package org.jason.flex01; Import Org.red5.server.adapter.ApplicationAdapter;  Public class extends applicationadapter{    }

2. The client uses flex to implement the camera to get the video and publish the code as follows:

<?XML version= "1.0" encoding= "Utf-8"?><mx:applicationxmlns:mx= "Http://www.adobe.com/2006/mxml"Layout= "Absolute"Applicationcomplete= "init ()">    <Mx:script>        <!--[cdata[import flash.net.NetConnection;            Import Flash.net.NetStream;            Import flash.events.NetStatusEvent;                        Import Mx.controls.Alert;            private Var nc:netconnection;            private Var Ns:netstream;                        private Var Cam:camera;                Private Function init (): void{NC = new Netconnection ();                Nc.addeventlistener (Netstatusevent.net_status,connectserverhander);                Nc.client = this;            Nc.connect ("rtmp://58.116.56.68:1935/flex01"); } Private Function Connectserverhander (evt:netstatusevent): void{Trace (Evt.info.code                 );                                Cam = Camera.getcamera ();                    if (cam! = null) {Cam.setmode (313,194,30);                    Cam.setquality (0,70);                     NS = new NetStream (NC);                    Ns.attachcamera (CAM); Ns.publish ("REd5 ");                    var vi:video = new Video ();                    Vi.width = 313;                    Vi.height = 194;                    Vi.attachcamera (CAM);                                    Videodisplay.addchild (vi);                }else{alert.show ("no Camera");                    }} Public Function Onbwdone (): void{} ]] -    </Mx:script>        <Mx:videodisplayx= "162"y= "The "width= "313"Height= "194"ID= "Videodisplay"/>    </mx:application>

The client uses the Flex play video code as follows:

<?XML version= "1.0" encoding= "Utf-8"?><mx:applicationxmlns:mx= "Http://www.adobe.com/2006/mxml"Layout= "Absolute"Applicationcomplete= "init ()">    <Mx:script>        <!--[cdata[import flash.display.*;            Import flash.utils.*;            Import flash.events.*;            Import flash.net.*;            Import Flash.media.Video;                        Import Flash.media.Camera;                        private Var nc:netconnection;                Private Function init (): void{NC = new Netconnection ();                Nc.connect ("rtmp://58.116.56.68:1935/flex01");            Nc.addeventlistener (Netstatusevent.net_status,connecthandler); } Private Function Connecthandler (evt:netstatusevent): void{var ns:netstream = n                EW NetStream (NC);                var video:video=new video ();                Video.width = 313;                Video.height = 194;                  Video.attachnetstream (NS);                Ns.play ("Red5");                            Videodisplay.addchild (video); }                    ]] -    </Mx:script>        <Mx:panelx= "the"y= "+"width= "356"Height= "266"Layout= "Absolute"title= "Live broadcast"fontSize= "+">        <Mx:videodisplayx= "Ten"y= "Ten"width= " the"Height= "193"ID= "Videodisplay"/>    </Mx:panel>    </mx:application>

Reference: Flex Syntax--http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html?utm_source=tuicool

Red5---> http://blog.csdn.net/oldmtn/article/details/47110351 of streaming media server

Http://blog.sina.com.cn/s/blog_4829b9400100rmz0.html

Develop simple video live features with Flex and Red5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.