summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@gmail.com>2017-08-09 10:24:04 +0300
committerGitHub <noreply@github.com>2017-08-09 10:24:04 +0300
commit40547e6914cd62ba6a718c00a2117451bf25c36d (patch)
tree28ae257d2e4890552317b429e67ae9ade30991ef /client
parent8ca1f5a677d4156b999942c852dc9fcb9eaf0e79 (diff)
downloadvaadin-framework-40547e6914cd62ba6a718c00a2117451bf25c36d.tar.gz
vaadin-framework-40547e6914cd62ba6a718c00a2117451bf25c36d.zip
Add loop and preload attributes for media elements, fix null poster (#9797)
Picked from #9161 Fixes #7261 Fixes #5178 Fixes #4409
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/ui/MediaBaseConnector.java9
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VMediaBase.java25
-rw-r--r--client/src/main/java/com/vaadin/client/ui/video/VideoConnector.java6
3 files changed, 39 insertions, 1 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/MediaBaseConnector.java b/client/src/main/java/com/vaadin/client/ui/MediaBaseConnector.java
index 0de1161078..9e457fa150 100644
--- a/client/src/main/java/com/vaadin/client/ui/MediaBaseConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/MediaBaseConnector.java
@@ -20,6 +20,7 @@ import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.shared.communication.URLReference;
import com.vaadin.shared.ui.AbstractMediaState;
import com.vaadin.shared.ui.MediaControl;
+import com.vaadin.shared.ui.PreloadMode;
public abstract class MediaBaseConnector extends AbstractComponentConnector {
@@ -53,6 +54,8 @@ public abstract class MediaBaseConnector extends AbstractComponentConnector {
final AbstractMediaState state = getState();
setAltText(state.altText); // must do before loading sources
+ setPreload(state.preload);
+ widget.setLoop(state.loop);
widget.setAutoplay(state.autoplay);
widget.setMuted(state.muted);
widget.setControls(state.showControls);
@@ -83,6 +86,12 @@ public abstract class MediaBaseConnector extends AbstractComponentConnector {
getWidget().setAltText(altText);
}
+ private void setPreload(final PreloadMode preload) {
+ if (preload != null) {
+ getWidget().setPreload(preload.getValue());
+ }
+ }
+
/**
* @return the default HTML to show users with browsers that do not support
* HTML5 media markup.
diff --git a/client/src/main/java/com/vaadin/client/ui/VMediaBase.java b/client/src/main/java/com/vaadin/client/ui/VMediaBase.java
index 1c7da7d15b..27ddc0fcc7 100644
--- a/client/src/main/java/com/vaadin/client/ui/VMediaBase.java
+++ b/client/src/main/java/com/vaadin/client/ui/VMediaBase.java
@@ -68,6 +68,31 @@ public abstract class VMediaBase extends Widget {
media.setMuted(mediaMuted);
}
+ /**
+ * Sets the preload attribute that is intended to provide a hint to the
+ * browser how the media should be preloaded. See
+ * AbstractMedia.setPreload(PreloadMode) and PreloadMode for more
+ * information.
+ *
+ * @param preload
+ * preload mode
+ * @since 7.7.11
+ */
+ public void setPreload(final String preload) {
+ media.setPreload(preload);
+ }
+
+ /**
+ * Enables or disables looping.
+ *
+ * @param loop
+ * if true, enable looping
+ * @since 7.7.11
+ */
+ public void setLoop(final boolean loop) {
+ media.setLoop(loop);
+ }
+
public void removeAllSources() {
NodeList<com.google.gwt.dom.client.Element> l = media
.getElementsByTagName(SourceElement.TAG);
diff --git a/client/src/main/java/com/vaadin/client/ui/video/VideoConnector.java b/client/src/main/java/com/vaadin/client/ui/video/VideoConnector.java
index 80e7788dea..14a2a86764 100644
--- a/client/src/main/java/com/vaadin/client/ui/video/VideoConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/video/VideoConnector.java
@@ -34,7 +34,11 @@ public class VideoConnector extends MediaBaseConnector {
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
- getWidget().setPoster(getResourceUrl(VideoConstants.POSTER_RESOURCE));
+
+ String resourceUrl = getResourceUrl(VideoConstants.POSTER_RESOURCE);
+ if (resourceUrl != null) {
+ getWidget().setPoster(resourceUrl);
+ }
}
@Override