1, 首先启动red5
3,在该页面点击installer,进入安装页面。或输入http://localhost:5080/installer/
4,安装oflaDemo
5,可能会报错,下面来解决这些基本问题。
5.1,重新编译Application.java
package org.red5.demos.oflaDemo; import org.red5.logging.Red5LoggerFactory; import org.red5.server.adapter.ApplicationAdapter; import org.red5.server.api.IConnection; import org.red5.server.api.IScope; import org.red5.server.api.stream.IServerStream; import org.red5.server.api.stream.IStreamCapableConnection; import org.slf4j.Logger; public class Application extends ApplicationAdapter { private static Logger log = Red5LoggerFactory.getLogger(Application.class, "oflaDemo"); private IScope appScope; private IServerStream serverStream; public Application() { log.info("oflaDemo created"); System.out.println("oflaDemo created"); } public boolean appStart(IScope app) { log.info("oflaDemo appStart"); System.out.println("oflaDemo appStart"); this.appScope = app; return true; } public boolean appConnect(IConnection conn, Object[] params) { log.info("oflaDemo appConnect"); measureBandwidth(conn); if ((conn instanceof IStreamCapableConnection)) { IStreamCapableConnection streamConn = (IStreamCapableConnection)conn; /** SimpleConnectionBWConfig bwConfig = new SimpleConnectionBWConfig(); bwConfig.getChannelBandwidth()[3] = 1048576L; bwConfig.getChannelInitialBurst()[3] = 131072L; streamConn.setBandwidthConfigure(bwConfig); */ } return super.appConnect(conn, params); } public void appDisconnect(IConnection conn) { log.info("oflaDemo appDisconnect"); if ((this.appScope == conn.getScope()) && (this.serverStream != null)) { this.serverStream.close(); } super.appDisconnect(conn); } }
5.2,增加所需要的jar文件spring-aop-3.0.5.RELEASE.jar和aopalliance-1.0.jar
6,重启Red5,访问路径http://localhost:5080/demos/ofla_demo.html,点击Connect,右侧变绿,出现播放列表。选择播放文件。
7,使用jwplayer,进行测试,书写代码如下
<script type="text/javascript" src="${pageContext.request.contextPath}/player/jwplayer.js"></script> <div id="myElement" >Loading the player...</div> jwplayer("myElement").setup({ file: "rtmp://localhost/oflaDemo/9.flv", height: 360, image: "${pageContext.request.contextPath}/images/button.gif", width: 640 });
正常播放则测试成功。
8,进行二次开发
8.1,先写Java类
package first; import org.red5.server.adapter.ApplicationAdapter; import org.red5.server.api.IConnection; import org.red5.server.api.IScope; import org.red5.server.api.stream.IServerStream; import org.red5.server.api.stream.IStreamCapableConnection; public class Application extends ApplicationAdapter { private IScope appScope; private IServerStream serverStream; public Application() { } public boolean appStart(IScope app) { this.appScope = app; return true; } public boolean appConnect(IConnection conn, Object[] params) { measureBandwidth(conn); if ((conn instanceof IStreamCapableConnection)) { IStreamCapableConnection streamConn = (IStreamCapableConnection)conn; } return super.appConnect(conn, params); } public void appDisconnect(IConnection conn) { if ((this.appScope == conn.getScope()) && (this.serverStream != null)) { this.serverStream.close(); } super.appDisconnect(conn); } }
8.2 配置red5-web.properties,内容如下
webapp.contextPath=/red58
webapp.virtualHosts=*
webapp.virtualHosts=*
8.3 配置red5-web.xml
<?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:lang="http://www.springframework.org/schema/lang" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd"> <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="/WEB-INF/red5-web.properties" /> </bean> <bean id="web.context" class="org.red5.server.Context" autowire="byType" /> <bean id="web.scope" class="org.red5.server.WebScope" init-method="register"> <property name="server" ref="red5.server" /> <property name="parent" ref="global.scope" /> <property name="context" ref="web.context" /> <property name="handler" ref="web.handler" /> <property name="contextPath" value="${webapp.contextPath}" /> <property name="virtualHosts" value="${webapp.virtualHosts}" /> </bean> <bean id="web.handler" class="first.Application" /> </beans>
8.4 配置web.xml
<?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>red58</display-name> <context-param> <param-name>webAppRootKey</param-name> <param-value>/red58</param-value> </context-param> <servlet> <servlet-name>rtmpt</servlet-name> <servlet-class>org.red5.server.net.rtmpt.RTMPTServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>rtmpt</servlet-name> <url-pattern>/fcs/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>rtmpt</servlet-name> <url-pattern>/open/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>rtmpt</servlet-name> <url-pattern>/close/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>rtmpt</servlet-name> <url-pattern>/send/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>rtmpt</servlet-name> <url-pattern>/idle/*</url-pattern> </servlet-mapping> <security-constraint> <web-resource-collection> <web-resource-name>Forbidden</web-resource-name> <url-pattern>/streams/*</url-pattern> </web-resource-collection> <auth-constraint/> </security-constraint> </web-app>
8.5 在WebContent\streams里放置flv等类型文件
8.6 发布文件,名称为red58
8.7,发布时,删除lib文件夹中的文件
8.8 进行测试。
<script type="text/javascript" src="${pageContext.request.contextPath}/player/jwplayer.js"></script> <div id="myElement" >Loading the player...</div> jwplayer("myElement").setup({ file: "rtmp://localhost/red58/9.flv", height: 360, image: "${pageContext.request.contextPath}/images/button.gif", width: 640 });
jwplayer().onBeforePlay( function(event){ //alert("before Play"); }); jwplayer().onPlay( function(event){ //alert(" Play"); }); jwplayer().onSeek( function(event){ //alert("before Play"); alert("seek--position:"+event.position +"---offset :"+event.offset ); }); jwplayer().onTime( function(event){ //this event is fired as the playback position gets updated //alert("onTime--position:"+event.position +"---duration :"+event.duration ); });
相关推荐
Red5 是一个采用 Java 开发的开源免费 Flash 流媒体服务器。Red5 基于 Java 和一些功能强大的开源框架,为企业级应用奠定了标准。它使用 RTMP,RTMPT,RTMPS 和 RTMPE 流媒体协议, 支持:将音频(MP3)和视频(FLV,...
1. 创建一个 Java 后台服务项目,添加 Dynamic web project(Red5Test),并添加相关文件,包括 Red5Test.java、web.xml、red5-web.xml 和 red5-web.properties。 2. 在 Red5Test.java 中,继承 ApplicationAdapter...
red5chatv2.1 red5建的一个FLASH视频聊天会议例子,有JAVA和FLASH源码
第一一部分 Red5 核心技术之安全 .................................. 第一二部分 Red5 核心技术之 脚本实现 ........................ 第一三部分 Red5 核心技术之集群 .................................. 第一四...
最近要做一个流媒体服务器,在网上逗留了好久决定选择red5。但是网上中文资料很少视频资料更是不敢奢望,只有啃一些英文文档了,http://hi.baidu.com/qjchina/blog/item/acf860594516542e2934f076.html是我的学习...
Red5 Server API 帮助文档 Red5是一个采用Java开发开源的Flash流媒体服务器
红5(Red5)作为一款开源的流媒体服务器软件,广受开发者和企业的青睐。今天,我们将从红5搭建流媒体直播系统的角度,详细解说其安装、设置、直播频道发布管理等相关知识点。 一、红5安装与设置 Red5是基于Java的...
red5是一个流媒体应用,本文主要讲述red5的安装后的配置
在flex,java 盛行天下时red...java,flex,spr ing,mina 等等等等都red5 相关,如果要对每一个点讲解那将是一个系列,而不是 一本书。为了突出重点,本书只讲解把这些联系起来的纽扣red5,并讲解如何利用red5 开 发项目。
会者不难,难者不会。当我们接触新的挑战时,阻碍我们的永远都是最初的那一步。只要我们迈出了这一步,心中豁然开朗。现在上传的是一个最最简单的hello word例子,希望对那些刚接触red5的人有所帮助
Red5是一个采用Java开发开源的Flash流媒体服务器。它支持:把音频(MP3)和视频(FLV)转换成播放流; 录制客户端播放流(只支持FLV);共享对象;现场直播流发布;远程调用。Red5使用RTMP作为流媒体传输协议,在其...
这是一款流媒体框架搭建的一个red5包,很好用哦!
有关Red5服务器集群应用的非常好的一片论文
Red5是一个开源的Flash服务器代码
Red5是一个采用Java 开发开源免费的的Flash 流媒体服务器,功能和Adobe 的fms(F lash Media Server)相同,它支持把音频(MP3) 和视频(FLV)转换成播放流,在下载的同时播放流; 录制客户端播放流(只支持FLV),...
本系列教程注重实战,不仅讲解了Red5的基础知识让同学们快速入门,还加入了实战项目力求带领您进入flex,red5结合开发的天堂。 本教程有四大部分组成:第一部分讲项目前预备知识,在线播放器程序全程贯穿,后三个...
Eclipse 创建第一个 Red5 应用程序初步
本实例从头到尾讲解了怎样用RED5来录制视频文件的过程。提供源代码。
Red5的主要功能和Macromedia公司的FMS类似,提供基于Flash的流媒体服务的一款基于Java的开源流媒体服务器。它由Java语言编写,使用RTMP作为流媒体传输协议,这与FMS完全兼容。它具有流化FLV、MP3文件,实时录制...
red5流媒体服务器是一款可以帮助您配置视频流的工具,可以将您设计的视频预先保存到服务器上,当您需要播放的时候,直接从服务器上下载您的媒体视频,这样就可以一般下载一遍查看了,这样传播视频的方式通常用于网页...