forked from j62/ctbrec
1
0
Fork 0

Improve mimetype handling for the HlsServlet

This commit is contained in:
0xb00bface 2020-09-24 21:05:59 +02:00
parent f0713b96f5
commit 6e63fae244
3 changed files with 34 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import java.util.Enumeration;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.activation.MimetypesFileTypeMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -85,7 +86,10 @@ public class HlsServlet extends AbstractCtbrecServlet {
}
private void serveSegment(HttpServletRequest req, HttpServletResponse resp, File requestedFile) throws IOException {
String mimetype = requestedFile.getName().endsWith(".mp4") ? "video/mp4" : "application/octet-stream";
MimetypesFileTypeMap map = new MimetypesFileTypeMap();
//String mimetype = requestedFile.getName().endsWith(".mp4") ? "video/mp4" : "application/octet-stream";
String mimetype = map.getContentType(requestedFile);
LOG.debug("Serving {} as {}", requestedFile.getName(), mimetype);
serveFile(req, resp, requestedFile, mimetype);
}

View File

@ -0,0 +1,27 @@
#
# A simple, old format, mime.types file
#
text/html html htm HTML HTM
text/plain txt text TXT TEXT
image/gif gif GIF
image/ief ief
image/jpeg jpeg jpg jpe JPG
image/tiff tiff tif
image/x-xwindowdump xwd
application/postscript ai eps ps
application/rtf rtf
application/x-tex tex
application/x-texinfo texinfo texi
application/x-troff t tr roff
audio/basic au
audio/midi midi mid
audio/x-aifc aifc
audio/x-aiff aif aiff
audio/x-mpeg mpeg mpg
audio/x-wav wav
video/mpeg mpeg mpg mpe
video/mp2t ts
video/mp4 mp4
video/webm webm mkv
video/quicktime qt mov
video/x-msvideo avi

View File

@ -1,3 +1,5 @@
body {overflow-y:scroll;}
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */