课件播放系统组件使用方法

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

搭建课件上传下载及播放

文件上传模块

前台页面提交文件

前台页面验证脚本

请选择需上传的教学课件(课件格式为PPT):

后台上传模块

public class AddVideoAction extends ActionSupport{

private static final long serialVersionUID = 1L;

private static final int BUFFER_SIZE = 8 *1024;

private File uploadFile;

private VideoService vs;

private String uploadFileFileName;

private String uploadFileContentType;

public VideoService getVs() {

return vs;

}

public void setVs(VideoService vs) {

this.vs = vs;

}

//上传到服务器

private static void copy(File src,File dst){

try{

InputStream in = null;

OutputStream os = null;

try{

in = new BufferedInputStream(new FileInputStream(src));

os = new BufferedOutputStream(new FileOutputStream(dst),BUFFER_SIZE);

byte []buffer = new byte[BUFFER_SIZE];

while( in.read(buffer) > 0){

os.write(buffer);

}

}finally{

if(null != in){

in.close();

}

if(null != os){

os.close();

}

}

}catch (Exception e){

e.printStackTrace();

}

}

public String execute()throws Exception{

SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");

if(null==ActionContext.getContext().getSession().get("currentAdmin"))

return"login";

String fileName = uploadFileFileName;

fileName = fileName.replace(" ","");

String playFileName = sdf.format(new Date())+".flv";

File playFile = new File(ServletActionContext.getServletContext().getRealPath("/upload/video/play") + "\\"+ playFileName);

File downloadFile = new File(ServletActionContext.getServletContext().getRealPath("/upload/video/download") + "\\" + fileName);

copy(uploadFile,downloadFile);

copy(uploadFile,playFile);

if( 1 == vs.addVideo(downloadFile,playFileName))

return SUCCESS;

return ERROR;

}

//文件的扩展名

public static String getExtention(String fileName){

相关文档
最新文档