Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Basic/Classic UI: support for HTTP Live Stream #4386

Merged
merged 1 commit into from Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -4,6 +4,6 @@
data-control-type="video"
data-widget-id="%widget_id%"
>
<video autoplay controls src="%url%"></video>
<video autoplay controls src="%url%" %media_type%></video>
</div>
</div>
Expand Up @@ -9,6 +9,8 @@

import org.apache.commons.lang.StringUtils;
import org.eclipse.emf.common.util.EList;
import org.eclipse.smarthome.core.library.types.StringType;
import org.eclipse.smarthome.core.types.State;
import org.eclipse.smarthome.model.sitemap.Video;
import org.eclipse.smarthome.model.sitemap.Widget;
import org.eclipse.smarthome.ui.basic.render.RenderException;
Expand Down Expand Up @@ -36,14 +38,22 @@ public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderExcep
String widgetId = itemUIRegistry.getWidgetId(w);
String sitemap = w.eResource().getURI().path();

if (videoWidget.getEncoding() != null && videoWidget.getEncoding().contains("mjpeg")) {
if (videoWidget.getEncoding() != null && videoWidget.getEncoding().toLowerCase().contains("mjpeg")) {
// we handle mjpeg streams as an html image as browser can usually handle this
snippet = getSnippet("image");
} else {
snippet = getSnippet("video");
}
String url = "../proxy?sitemap=" + sitemap + "&widgetId=" + widgetId;
String mediaType = "";
if (videoWidget.getEncoding() != null && videoWidget.getEncoding().toLowerCase().contains("hls")) {
// For HTTP Live Stream we don't proxy the URL and we set the appropriate media type
State state = itemUIRegistry.getState(w);
url = (state instanceof StringType) ? state.toString() : videoWidget.getUrl();
mediaType = "type=\"application/vnd.apple.mpegurl\"";
}
snippet = StringUtils.replace(snippet, "%url%", url);
snippet = StringUtils.replace(snippet, "%media_type%", mediaType);
snippet = preprocessSnippet(snippet, videoWidget);

sb.append(snippet);
Expand Down
@@ -1 +1 @@
<p><center><video style="padding:10px;width:90%" autoplay controls src="%url%"/></center></p>
<p><center><video style="padding:10px;width:90%" autoplay controls src="%url%" %media_type%/></center></p>
Expand Up @@ -9,6 +9,8 @@

import org.apache.commons.lang.StringUtils;
import org.eclipse.emf.common.util.EList;
import org.eclipse.smarthome.core.library.types.StringType;
import org.eclipse.smarthome.core.types.State;
import org.eclipse.smarthome.model.sitemap.Video;
import org.eclipse.smarthome.model.sitemap.Widget;
import org.eclipse.smarthome.ui.classic.render.RenderException;
Expand Down Expand Up @@ -36,7 +38,7 @@ public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderExcep
String widgetId = itemUIRegistry.getWidgetId(w);
String sitemap = w.eResource().getURI().path();

if (videoWidget.getEncoding() != null && videoWidget.getEncoding().contains("mjpeg")) {
if (videoWidget.getEncoding() != null && videoWidget.getEncoding().toLowerCase().contains("mjpeg")) {
// we handle mjpeg streams as an html image as browser can usually handle this
snippet = getSnippet("image");
snippet = StringUtils.replace(snippet, "%setrefresh%", "");
Expand All @@ -45,7 +47,15 @@ public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderExcep
snippet = getSnippet("video");
}
String url = "../proxy?sitemap=" + sitemap + "&widgetId=" + widgetId;
String mediaType = "";
if (videoWidget.getEncoding() != null && videoWidget.getEncoding().toLowerCase().contains("hls")) {
// For HTTP Live Stream we don't proxy the URL and we set the appropriate media type
State state = itemUIRegistry.getState(w);
url = (state instanceof StringType) ? state.toString() : videoWidget.getUrl();
mediaType = "type=\"application/vnd.apple.mpegurl\"";
}
snippet = StringUtils.replace(snippet, "%url%", url);
snippet = StringUtils.replace(snippet, "%media_type%", mediaType);
sb.append(snippet);
return null;
}
Expand Down