文档,影音的的在线浏览
来源:互联网 发布:桌秀美化软件 编辑:程序博客网 时间:2024/04/29 08:27
实现文档,音频视频在线浏览
1.后台写法
@RequestMapping(value="onLineBrowseOfficeDoc") public ModelAndView onLineBrowseOfficeDoc(@Context HttpServletRequest request, @Context HttpServletResponse response) { ModelAndView mv = new ModelAndView(); PageData pd = this.getPageData(); try { String requestUrl = request.getRequestURL().toString(); String contentName = request.getContextPath(); int contentNameIndex = requestUrl.indexOf(contentName); String serverPath = requestUrl.substring(0, contentNameIndex + 1); PageData pdd = dataResourcesFacade.findById(pd); String reletivePath = pdd.getString("RI_URL").replace("1_ADMIN", "1_admin"); String root = getContextRealPath(); //获取工程根路径 String filePath = root + reletivePath; File file = new File(filePath); boolean isExists = file.exists(); //文件不存在,返回null if(!isExists){ mv.setViewName("system/noExist"); mv.addObject("pd", pd); return mv; } int index = filePath.lastIndexOf("."); String fileExt = filePath.substring(index + 1); String tempContentName = contentName.substring(1); String returnPath = serverPath + tempContentName + "/" + reletivePath; int convertResult = -1; if(fileExt != null && !fileExt.equals("") && fileExt.equalsIgnoreCase("pdf")) { returnPath = returnPath.replaceAll("\\\\", "/"); pd.put("pdfsrc", returnPath); mv.setViewName("meeting/PdfViewer"); mv.addObject("pd", pd); return mv; } else if(fileExt.equalsIgnoreCase("doc") || fileExt.equalsIgnoreCase("docx") || fileExt.equalsIgnoreCase("xls") || fileExt.equalsIgnoreCase("xlsx") || fileExt.equalsIgnoreCase("ppt") || fileExt.equalsIgnoreCase("pptx")) { filePath = filePath.replaceAll("\\\\", "/"); index = filePath.lastIndexOf("/"); File returnFolder = new File(filePath.substring(0, index)); if(!returnFolder.exists()) returnFolder.mkdirs(); returnPath = filePath.substring(0, filePath.lastIndexOf(".")) + ".pdf"; File file2 = new File(returnPath); boolean isExists2 = file2.exists(); //文件不存在则进行转换 if(!isExists2){ convertResult = office2PDF(filePath, returnPath); }else{ convertResult=0; } } else if (fileExt.equalsIgnoreCase("mp4") || fileExt.equalsIgnoreCase("avi") || fileExt.equalsIgnoreCase("mp3") || fileExt.equalsIgnoreCase("aac") || fileExt.equalsIgnoreCase("wav") || fileExt.equalsIgnoreCase("ogg")) { returnPath = returnPath.replaceAll("\\\\", "/"); pd.put("pdfsrc", returnPath); pd.put("suffixName",fileExt); mv.setViewName("meeting/fileViewVideo"); /* mv.setViewName("meeting/VideoViewer");*/ mv.addObject("pd", pd); return mv; } /* else if (fileExt.equalsIgnoreCase("avi") || fileExt.equalsIgnoreCase("wmv") || fileExt.equalsIgnoreCase("3gp") || fileExt.equalsIgnoreCase("mpg") || fileExt.equalsIgnoreCase("flv") || fileExt.equalsIgnoreCase("mov")) { returnPath = returnPath.replaceAll("\\\\", "/"); pd.put("pdfsrc", returnPath); mv.setViewName("meeting/VideoViewer"); mv.setViewName("meeting/fileViewVideo"); mv.addObject("pd", pd); return mv;// filePath = filePath.replaceAll("\\\\", "/");// index = filePath.lastIndexOf("/");//// File returnFolder = new File(filePath.substring(0, index));// if (!returnFolder.exists())// returnFolder.mkdirs();// returnPath = filePath.substring(0, filePath.lastIndexOf("."))// + ".mp4";//// File file2 = new File(returnPath);// boolean isExists2 = file2.exists(); // 文件不存在则进行转换// if (!isExists2) {// convertResult = Video2MP4(filePath, returnPath);// } else {// convertResult = 0;// }// pd.put("pdfsrc", returnPath);// mv.setViewName("meeting/PdfViewer");// mv.addObject("pd", pd);// return mv; }*/ else return null; if(convertResult == 0) { returnPath = serverPath + returnPath.substring(returnPath.indexOf(contentName) + 1); //returnPath="http://127.0.0.1:8080/DIIT-Web-OneMap/uploadFiles/1_admin/Document/123.pdf"; //pd.put("pdfsrc", URLEncoder.encode(returnPath,"utf-8")); pd.put("pdfsrc", returnPath); mv.setViewName("meeting/PdfViewer"); mv.addObject("pd", pd); return mv; } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
2文档类前端写法
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ page isELIgnored="false" %> <!DOCTYPE HTML><html> <head> <base href="<%=basePath%>"> <title>pdf在线浏览</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <link rel="icon" type="image/png" href="static/assets/images/sign_Logo.png"> <script type="text/javascript" src="static/js/jquery-1.9.1.min.js"></script> <script type="text/javascript" src="static/js/pdfobject.js"></script> <style> html,body,.pdfobject-container{ height:100%; width:100%; margin:0px; padding:0px; } </style> </head> <body> <div id="pdfDiv"></div> <script>// $(".pdfobject-container").height($(document).height()); var src = "${pd.pdfsrc}"; PDFObject.embed(src, "#pdfDiv"); </script> </body></html>
3.在线音视频浏览
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML><html lang="zh-CN"><head> <link href="<%=basePath%>static/js/video/css/video-js.css" rel="stylesheet"> <style> #container,#table{ position: fixed; top: 0px; left: 0px; right: 0px; bottom: 0px; margin: auto; display:none; } </style><script type="text/javascript" src="<%=basePath%>static/js/jwplayer-7.2.2/jwplayer.js"></script><script type="text/javascript" src="<%=basePath%>static/js/jwplayer-7.2.2/provider.shaka.js"></script><script type="text/javascript">jwplayer.key="W+FSSIJICMeqqi4MQCwmdLePq9iq8HQqiVT5dQ==";</script><script>$(function() { var suffixName='${pd.suffixName}';alert(suffixName);});function userJWPlayer(){ jwplayer ( "container" ). setup ({ flashplayer : "<%=basePath%>static/js/jwplayer-7.2.2/jwplayer.flash.swf" , file : "<%=basePath%>uploadFiles/1_admin/AudioVisual/test.mp4" , height : 600, width : 800 });}</script></head><body bgcolor=aquamarine> <div id = "container">Loading the player ...</div> <table width=100% height=100% id="table"> <tr> <td align="center" valign="middle"><object id="video1" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="800" height="500" type="application/x-mplayer2" border="0"> <param name="ShowDisplay" value="0"> <param name="ShowControls" value="1"> <param name="AutoStart" value="-1"> <param name="AutoRewind" value="0"> <param name="PlayCount" value="1"> <param name="Appearance value=" 0 value="""> <param name="BorderStyle value=" 0 value="""> <param name="MovieWindowHeight" value="500"> <param name="MovieWindowWidth" value="800"> <embed width="900" height="600" border="0" showdisplay="0" showcontrols="1" playcount="0" src="<%=basePath%>uploadFiles/1_admin/AudioVisual/Chains.aac"> </embed> </object></td> </tr> </table> </body></html>
阅读全文
0 0
- 文档,影音的的在线浏览
- (六)java实现文档的在线浏览-flexpaper在线浏览swf文档
- (一)java实现文档的在线浏览-简介
- 利用FlexPaper模仿百度文库实现文档的在线浏览
- (三)java实现文档的在线浏览-使用JODConverter将office文档转换为pdf
- pdf文件的在线浏览
- Word,Excel,Powerpoint,Txt,Pdf 等文档的在线浏览的实现
- (五)java实现文档的在线浏览-转换pdf的同时转为swf
- (七)java实现文档的在线浏览-使用过程中产生的问题
- 基于动易网站管理系统的文档在线浏览应用
- (二)java实现文档的在线浏览-安装openoffice.org
- (四)java实现文档的在线浏览-使用swftools将pdf转换为swf
- FlexPaper实现文档在线浏览
- flexpaper实现文档在线浏览
- FlexPaper实现文档在线浏览
- javaapi的在线文档
- 在线浏览的几种方法
- 用FLEX做文件的在线浏览
- Address already in use: JVM_Bind(端口冲突)
- 禁止微信缓存
- Java Collection Framework 中List 和 Map遍历总结
- 远程监管系统概要设计
- Backbone简介
- 文档,影音的的在线浏览
- 多态,及向上下转型
- Spring Cloud netflix概览和架构设计
- spring boot slf4j 配置日志记录
- 微信小程序登陆及登陆状态保持前后端php代码 缓存redis
- python_lintcode_167链表求和
- jsp标签库和隐含对象的用法
- HDU 5861 Road (线段树区间设值)
- JS前端合并TABLE相同列的单元格