Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTML 5 player video function
Browse files Browse the repository at this point in the history
fix #219
gnujavasergio committed Jul 12, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 6f5725a commit abcaba0
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions src/main/java/com/openkm/servlet/PreviewServlet.java
Original file line number Diff line number Diff line change
@@ -199,45 +199,19 @@ private void buildUrl(PreviewParams params, Document doc) throws DatabaseExcepti
/**
* Get PDF preview. Look into profile to get configured preview
*/
private void pdfPreview(PreviewParams params) throws ServletException, IOException, AccessDeniedException,
PathNotFoundException, DatabaseException, PrincipalAdapterException {
String selectedPreview = getDesiredPreview(params);

if (PREVIEWER_PDFJS.equals(selectedPreview)) {
pdfjs(params);
} else {
flexpaper(params);
}
private void pdfPreview(PreviewParams params) throws IOException, PrincipalAdapterException {
pdfjs(params);
}

/**
* Show PDF.js preview
*/
private void pdfjs(PreviewParams params) throws IOException {
String contextPath = params.request.getContextPath();
String url = contextPath + "/preview/pdfjs/index.jsp?pdfUrl="+URLEncoder.encode(params.pdfUrl, "UTF-8");
String url = contextPath + "/preview/pdfjs/index.jsp?pdfUrl=" + URLEncoder.encode(params.pdfUrl, "UTF-8");
params.response.sendRedirect(url);
}

/**
* Get desired preview
*/
private String getDesiredPreview(PreviewParams params) throws PrincipalAdapterException {
Profile profile = OKMAuth.getInstance().getUserProfile(null, PrincipalUtils.getUser());
String desiredPreview = PREVIEWER_PDFJS;

// previewEngine should have priority over the other options
if (params.previewEngine != null && !params.previewEngine.isEmpty() && (PREVIEWER_PDFJS.equals(params.previewEngine))) {
// Only use if there is a valid preview engine as parameter
desiredPreview = params.previewEngine;
} else if (profile != null) {
// The first option is to use profile previewer
desiredPreview = profile.getPrfMisc().getPreviewer();
}

return desiredPreview;
}

/**
* Show html preview
*/

0 comments on commit abcaba0

Please sign in to comment.