课件播放系统组件使用方法.docx
- 文档编号:3161338
- 上传时间:2022-11-18
- 格式:DOCX
- 页数:14
- 大小:19.81KB
课件播放系统组件使用方法.docx
《课件播放系统组件使用方法.docx》由会员分享,可在线阅读,更多相关《课件播放系统组件使用方法.docx(14页珍藏版)》请在冰豆网上搜索。
课件播放系统组件使用方法
搭建课件上传下载及播放
文件上传模块
前台页面提交文件
前台页面验证脚本
$(document).ready(function(){
$(document.form).submit(function(){
varfile=(document.getElementById("file")).value;
varname=".ppt";
if((file.indexOf(name,file.length-4))<0){
alert("文件格式不对!
请重新选择");
returnfalse;
}
returntrue;
});
});
formaction="addPPt"method="post"enctype="multipart/form-data"id="form"name="form"> 请选择需上传的教学课件(课件格式为PPT):
form>
后台上传模块
publicclassAddVideoActionextendsActionSupport{
privatestaticfinallongserialVersionUID=1L;
privatestaticfinalintBUFFER_SIZE=8*1024;
privateFileuploadFile;
privateVideoServicevs;
privateStringuploadFileFileName;
privateStringuploadFileContentType;
publicVideoServicegetVs(){
returnvs;
}
publicvoidsetVs(VideoServicevs){
this.vs=vs;
}
//上传到服务器
privatestaticvoidcopy(Filesrc,Filedst){
try{
InputStreamin=null;
OutputStreamos=null;
try{
in=newBufferedInputStream(newFileInputStream(src));
os=newBufferedOutputStream(newFileOutputStream(dst),BUFFER_SIZE);
byte[]buffer=newbyte[BUFFER_SIZE];
while(in.read(buffer)>0){
os.write(buffer);
}
}finally{
if(null!
=in){
in.close();
}
if(null!
=os){
os.close();
}
}
}catch(Exceptione){
e.printStackTrace();
}
}
publicStringexecute()throwsException{
SimpleDateFormatsdf=newSimpleDateFormat("yyyyMMddHHmmss");
if(null==ActionContext.getContext().getSession().get("currentAdmin"))
return"login";
StringfileName=uploadFileFileName;
fileName=fileName.replace("","");
StringplayFileName=sdf.format(newDate())+".flv";
FileplayFile=newFile(ServletActionContext.getServletContext().getRealPath("/upload/video/play")+"\\"+playFileName);
FiledownloadFile=newFile(ServletActionContext.getServletContext().getRealPath("/upload/video/download")+"\\"+fileName);
copy(uploadFile,downloadFile);
copy(uploadFile,playFile);
if(1==vs.addVideo(downloadFile,playFileName))
returnSUCCESS;
returnERROR;
}
//文件的扩展名
publicstaticStringgetExtention(StringfileName){
intpos=fileName.lastIndexOf(".");
returnfileName.substring(pos);
}
publicFilegetUploadFile(){
returnuploadFile;
}
publicvoidsetUploadFile(FileuploadFile){
this.uploadFile=uploadFile;
}
publicStringgetUploadFileFileName(){
returnuploadFileFileName;
}
publicvoidsetUploadFileFileName(StringuploadFileFileName){
this.uploadFileFileName=uploadFileFileName;
}
publicStringgetUploadFileContentType(){
returnuploadFileContentType;
}
publicvoidsetUploadFileContentType(StringuploadFileContentType){
this.uploadFileContentType=uploadFileContentType;
}
}
文件下载模块
文件下载模块
publicclassDownLoadFileActionextendsActionSupport{
privatestaticfinallongserialVersionUID=1L;
privateStringfileName;
privateStringtype;
publicStringcontentType;
privateVideoServicevs;
privatePPtServiceps;
privateintid;
publicintgetId(){
returnid;
}
publicvoidsetId(intid){
this.id=id;
}
publicVideoServicegetVs(){
returnvs;
}
publicvoidsetVs(VideoServicevs){
this.vs=vs;
}
publicPPtServicegetPs(){
returnps;
}
publicvoidsetPs(PPtServiceps){
this.ps=ps;
}
publicInputStreamgetDownloadFile(){
if(type.equals("ppt")){
contentType="application/vnd.ms-powerpoint";
returnServletActionContext.getServletContext().getResourceAsStream(
"/upload/ppt/"+getDownLoadChineseFileName());
}
else{
contentType="application/x-shockwave-flash";
returnServletActionContext.getServletContext().getResourceAsStream(
"/upload/video/download/"+getDownLoadChineseFileName());
}
}
publicStringgetDownLoadChineseFileName(){
StringdownloadChineseFileName=fileName;
try{
downloadChineseFileName=newString(downloadChineseFileName.getBytes("ISO8859-1"),"gbk");
System.out.println(downloadChineseFileName);
}catch(UnsupportedEncodingExceptione){
e.printStackTrace();
}
returndownloadChineseFileName;
}
publicStringexecute()throwsException{
if(type.equals("ppt"))
ps.updateDtime(id);
else
vs.updateDtime(id);
//ServletActionContext.getResponse().setHeader("Content-Disposition","attachment;filename="+getDownLoadChineseFileName());
returnSUCCESS;
}
publicStringgetFileName(){
returngetDownLoadChineseFileName();
}
publicvoidsetFileName(StringfileName){
this.fileName=fileName;
}
publicStringgetType(){
returntype;
}
publicvoidsetType(Str
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 课件 播放 系统 组件 使用方法