support for indexing WebM videos
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Mon, 4 May 2015 16:48:13 +0000 (19:48 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Mon, 4 May 2015 16:48:13 +0000 (19:48 +0300)
src/main/java/eu/svjatoslav/meviz/htmlindexer/AbstractIndexer.java
src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java
src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java

index fff1b68..294189b 100644 (file)
@@ -44,6 +44,8 @@ public abstract class AbstractIndexer {
 
                                if ("ogv".equals(fileExtension))
                                        layout.enlistOgv(file, directory);
+                               else if ("webm".equals(fileExtension))
+                                       layout.enlistWebm(file, directory);
                                else
                                        layout.enlistFile(file, directory);
 
index b41d83a..4a21863 100755 (executable)
@@ -76,4 +76,6 @@ public interface Layout {
         */
        public void init(String galleryTitle, List<String> path,
                        final AbstractIndexer indexer, IndexingContext context);
+
+       public void enlistWebm(AbstractFile file, DirectoryMetadata directory);
 }
index fd70b10..f721ba6 100755 (executable)
@@ -164,7 +164,7 @@ public class MixedLayout implements Layout {
                filesHtml.append("<a href=\""
                                + indexingContext.getGlobalUrl()
                                + UrlParamEncoder.encode(indexingContext.getLocalUrl() + "/"
-                                               + file.fileName) + "\">download as OGV</a>");
+                                               + file.fileName) + "\">download as OGV file</a>");
 
                filesHtml.append("</div>\n");
 
@@ -272,4 +272,40 @@ public class MixedLayout implements Layout {
                return html.toString();
        }
 
+       @Override
+       public void enlistWebm(AbstractFile abstractFile,
+                       DirectoryMetadata directory) {
+               final GeneralFile file = (GeneralFile) abstractFile;
+
+               filesHtml.append("<div style=\"margin: 30px; clear: both;\">");
+
+               // watchable video
+
+               String fileUrl = indexingContext.getGlobalUrl()
+                               + UrlParamEncoder.encode(indexingContext.getLocalUrl() + "/"
+                                               + file.fileName);
+
+               filesHtml.append("<video controls>\n");
+               filesHtml.append("  <source src=\"" + fileUrl
+                               + "\" type='video/webm;codecs=\"vp8, opus\"'/>\n");
+               filesHtml.append("</video>\n");
+               filesHtml.append("<br/>\n");
+
+               // video title
+               filesHtml
+                               .append("Video: <b>"
+                                               + FilePathParser
+                                                               .getFileNameWithoutExtension(file.fileName)
+                                               + "<b/>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
+
+               // video download link
+               filesHtml.append("<a href=\""
+                               + indexingContext.getGlobalUrl()
+                               + UrlParamEncoder.encode(indexingContext.getLocalUrl() + "/"
+                                               + file.fileName) + "\">download as WebM file</a>");
+
+               filesHtml.append("</div>\n");
+
+               filesHtml.append("\n");
+       }
 }