利用red5实现视频在线播放

 安装好red5后先访问http:\\localhost:5080主页,然后安装名为oflaDemo的demo,到webapps里找到该项目后增加一个class文件,java代码如下:

package org.red5.demos.oflaDemo;

import org.red5.server.api.scope.IScope;
import org.red5.server.api.stream.IStreamFilenameGenerator;
import org.red5.server.api.stream.IStreamFilenameGenerator.GenerationType;

public class CustomFilenameGenerator
  implements IStreamFilenameGenerator
{
  public String recordPath;
  public String playbackPath;

  public String generateFilename(IScope scope, String name, IStreamFilenameGenerator.GenerationType type)
  {
    return generateFilename(scope, name, null, type);
  }

  public String generateFilename(IScope scope, String name, String extension, IStreamFilenameGenerator.GenerationType type)
  {
    String filename;
    String filename;
    if (type == IStreamFilenameGenerator.GenerationType.RECORD)
      filename = this.recordPath + name;
    else {
      filename = this.playbackPath + name;
    }
    if (extension != null)
    {
      filename = filename + extension;
    }
    return filename;
  }
  public void setRecordPath(String path) {
    this.recordPath = path;
  }

  public void setPlaybackPath(String path) {
    this.playbackPath = path;
  }

  public boolean resolvesToAbsolutePath() {
    return true;
  }
}

然后修改配置文件red5—web.xml增加如下内容(我把默认播放目录改为e盘)

    
    
  
  然后就可以利用jwplayer播放了,部分页面代码如下: 
This text will be replaced
 

  

你可能感兴趣的:(red5)