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;
}
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,进行测试,书写代码如下
Loading the player...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=*
8.3 配置red5-web.xml
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:lang="http://www.springfr 《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》 【docs.qq.com/doc/DSmxTbFJ1cmN1R2dB】 完整内容开源分享 amework.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"> 8.4 配置web.xml 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”> red58 webAppRootKey /red58 rtmpt org.red5.server.net.rtmpt.RTMPTServlet 1 rtmpt /fcs/* rtmpt /open/* rtmpt /close/* rtmpt /send/* rtmpt /idle/*



