Use eclipse to create the first red5 application example-use red5 to record videos online

Source: Internet
Author: User

Sample source code
Book connection ~ How to Use the red5 plug-in to create a red5 project? The next step is to see the effect of running applications developed in eclipse. This document uses an example to describe how to use red5 to record videos online.
Step 1:Install red5.
In Linux, you can refer to "how to install red5 on a Linux Server?";
Under Windows can go to the http://wiki.red5.org/wiki/0_9_1 to download the setup-Red5-0.9.1.exe, Installation Steps basically crazy "Next", but finally need to enter the IP and port number, that is the test page needs, IP directly input "localhost ", you can enter the port number 5080. It is worth noting that after red5 is successfully installed, the service is automatically started by default. We need to set its automatic start to manual. Because red5 in Windows is used for testing, after eclipse modifies the project and deploys it, debug starts
The server is red5. If the red5 service is started, an error occurs. This is similar to debugging a project in eclipse-Tomcat. We will not use Tomcat as a service in windows and start it automatically, right?
Step 2:Install two red5 demos.
This is required in this example. Install the messagerecorder and oflademo demos. After the red5 service is started, visit http: // localhost: 5080/. Click the install link on the page to bring up the red5 application installation list page. Select messagerecorder, oflademo, click the Install button in the lower-right corner. After the installation is successful, two new directories will be found in the red5 installation directory: messagerecorder and oflademo.
If you do not understand this step, you can watch the video.

Http://www.youtube.com/watch? V = 969cmygu1yw.

Step 3:Create a red5 project in eclipse.
Refer to the previous blog "How to Use the red5 plug-in to create a red5 project?", The project name in this article is also examplewebpro, just like the project name in this example.
Step 4:Create a new project in flex builder 3.

The project name is pzaixianluzhi. The content of pzaixianluzhi. mxml is as follows:

<? XML version = "1.0" encoding = "UTF-8"?> <Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute"> <mx: uicomponent id = "UI"> </MX: uicomponent> <mx: SCRIPT> <! [CDATA [import MX. controls. alert; private var rtmpurl: String = "rtmp: // localhost/examplewebpro"; private var Conn: netconnection = new netconnection (); Private var isconnectsuccess: Boolean = false; private var netstream: netstream; private var video: Video = new video (); Private function clickconnect (E: mouseevent): void {If (! Isconnectsuccess) {Conn. addeventlistener (netstatusevent. net_status, netstatus); Conn. connect (rtmpurl) ;}} private function clickvideo (E: mouseevent): void {video. attachcamera (camera. getcamera (); UI. addchild (video);} private function netstatus (E: netstatusevent): void {trace (e.info. code); If (e.info. code = "netconnection. connect. success ") {isconnectsuccess = true; netstream = new netstream (conn); netstream. client = new streamclient (); netstream. attachaudio (microphone. getmicrophone (); netstream. attachcamera (camera. getcamera (); netstream. publish ("nameffff", "record") ;}}]> </MX: SCRIPT> <mx: button x = "378" Y = "369" label = "Recording" Click = "this. clickconnect (event) "fontsize =" 16 "/> <mx: button x = "310" Y = "369" label = "video" fontsize = "16" Click = "this. clickvideo (event) "/> </MX: Application>

The streamclient. As source code called by pzaixianluzhi. mxml is as follows:

package{public class StreamClient{public function StreamClient(){}public function onMetaData(info:Object):void{for(var n:* in info){trace(n+":"+info[n]);}}public function onPlayStatus(info:Object):void{for(var n:* in info){trace(n+":"+info[n]);}}}}

Click the run option in the menu bar and select Run pzaixianshipin. In the displayed browser, click "video" to view your local video. -- Currently, most laptops have their own video headers. If you are using a PC without a video header, you should borrow a video header if you want to run this example. Haha.
Step 5:Debug and run the red5 Project.
Follow the instructions in "how to install red5 on a Linux Server?" Debug to start the red5 server, and then press the "video" button after Step 4 to start the local video, and then click "Recording" to call red5 service examplewebpro for recording. The eclipse console reports an error. The information is as follows:
Org red5 Server Net rtmp rtmphandler scope examplewebpro not found on localhost
In the past, the Eclipse plug-in of red5 was not as intelligent as the Tomcat plug-in, and the self-written program could not be identified. What should I do?
Step 6:Manually configure the red5 project created in step 3.

Copy the WEB-INF and red5-web.properties files under % red5 % webapps/messagerecorder/red5-web.xml to the WEB-INF of the examplewebpro project and add the following in Web. xml:

<context-param><param-name>webAppRootKey</param-name><param-value>/ExampleWebPro</param-value></context-param>

Then edit the red5-web.properties and change the webapp. contextpath value to/examplewebpro.
Step 7:Debug the red5 Project.
Repeat Step 5 to debug and run the red5 project and find that the project is running normally. The streams folder is generated under the % red5 %/webapps/examplewebpro Project, which contains the online recorded video nameffff. FLV. Successful.

Related Article

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.