1 /*******************************************************************************
2 * Copyright � Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
3 * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
4 * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
6 * This file is part of the work and learning management system Pentila Nero.
8 * Pentila Nero is free software. You can redistribute it and/or modify since
9 * you respect the terms of either (at least one of the both license) :
10 * - under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 * - the CeCILL-C as published by CeCILL-C; either version 1 of the
14 * License, or any later version
15 * - the GNU Lesser General Public License as published by the
16 * Free Software Foundation, either version 3 of the license,
17 * or (at your option) any later version.
19 * There are special exceptions to the terms and conditions of the
20 * licenses as they are applied to this software. View the full text of
21 * the exception in file LICENSE-PROJECT.txt in the directory of this software
24 * Pentila Nero is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * Licenses for more details.
29 * You should have received a copy of the GNU Affero General Public License
30 * and the CeCILL-C and the GNU Lesser General Public License along with
31 * Pentila Nero. If not, see :
32 * <http://www.gnu.org/licenses/> and
33 * <http://www.cecill.info/licences.fr.html>.
34 ******************************************************************************/
35 package com.pentila.entSavoie.utils;
37 import java.io.UnsupportedEncodingException;
39 import java.net.URLEncoder;
41 import java.util.ArrayList;
42 import java.util.Date;
43 import java.util.List;
45 import com.liferay.portal.kernel.log.Log;
46 import com.liferay.portal.kernel.log.LogFactoryUtil;
48 public class MediaPlayerUtil {
51 * Check if file need to be converted
52 * @param fileExtension a string which contains the file type
53 * @return the target type or the original if the file doesn't need to be converted
54 * @throws PortalException
55 * @throws SystemException
57 public static String getTargetExtension(String fileExtension) {
59 List<String> pdfTypeList = getPdfConversionTypeList();
61 if (pdfTypeList.contains(fileExtension)) {
65 List<String> mp3TypeList = getMp3ConversionTypeList();
67 if (mp3TypeList.contains(fileExtension)) {
71 List<String> mp4TypeList = getMp4ConversionTypeList();
73 if (mp4TypeList.contains(fileExtension)) {
81 * Check if file can be display in the viewer
82 * @param fileExtension a string which contains the file type
83 * @return true if the file is handled by the viewer
84 * @throws PortalException
85 * @throws SystemException
87 public static boolean hasViewer(String fileExtension) {
89 List<String> listContentTypeSupport = supportedTypeList();
91 if (listContentTypeSupport.contains(fileExtension)) {
99 * Get all file types which are converted to pdf
100 * @return a list which contains strings of all extensions converted to pdf
102 private static List<String> getImageTypeList() {
103 List<String> typeList = new ArrayList<String>();
106 typeList.add("jpeg");
114 * Get all file types which are converted to pdf
115 * @return a list which contains strings of all extensions converted to pdf
117 private static List<String> getPdfConversionTypeList() {
118 List<String> typeList = new ArrayList<String>();
133 //typeList.add("wpd");
134 typeList.add("docx");
135 typeList.add("xlsx");
136 typeList.add("pptx");
142 * Get all audio types which are converted to mp3
143 * @return a list which contains strings of all extensions converted to mp3
145 private static List<String> getMp3ConversionTypeList() {
146 List<String> typeList = new ArrayList<String>();
155 * Get all video types which are converted to mp4
156 * @return a list which contains strings of all extensions converted to mp4
158 private static List<String> getMp4ConversionTypeList() {
159 List<String> typeList = new ArrayList<String>();
165 typeList.add("mpeg");
172 * Get all file types that we can display in the viewer
173 * @return a list which contains strings of all the extensions handled
175 private static List<String> supportedTypeList() {
176 List<String> supportedTypeList = new ArrayList<String>();
179 supportedTypeList.add("pdf");
180 supportedTypeList.add("html");
181 supportedTypeList.addAll(getPdfConversionTypeList());
184 supportedTypeList.add("gif");
185 supportedTypeList.add("jpeg");
186 supportedTypeList.add("jpg");
187 supportedTypeList.add("png");
190 supportedTypeList.add("mp3");
191 supportedTypeList.addAll(getMp3ConversionTypeList());
194 supportedTypeList.add("mp4");
195 supportedTypeList.addAll(getMp4ConversionTypeList());
198 supportedTypeList.add("epub");
200 return supportedTypeList;
203 private static Log _log = LogFactoryUtil.getLog(MediaPlayerUtil.class);