From 40547e6914cd62ba6a718c00a2117451bf25c36d Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Wed, 9 Aug 2017 10:24:04 +0300 Subject: Add loop and preload attributes for media elements, fix null poster (#9797) Picked from #9161 Fixes #7261 Fixes #5178 Fixes #4409 --- .../com/vaadin/shared/ui/AbstractMediaState.java | 16 +++++++ .../java/com/vaadin/shared/ui/PreloadMode.java | 49 ++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 shared/src/main/java/com/vaadin/shared/ui/PreloadMode.java (limited to 'shared/src/main') diff --git a/shared/src/main/java/com/vaadin/shared/ui/AbstractMediaState.java b/shared/src/main/java/com/vaadin/shared/ui/AbstractMediaState.java index d7cddf566a..6d5024a324 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/AbstractMediaState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/AbstractMediaState.java @@ -36,6 +36,22 @@ public class AbstractMediaState extends AbstractComponentState { @NoLayout public boolean muted; + /** + * Preload mode for the media. + * + * @since 7.7.11 + */ + @NoLayout + public PreloadMode preload; + + /** + * Looping of media active (true) or not. + * + * @since 7.7.11 + */ + @NoLayout + public boolean loop; + public List sources = new ArrayList<>(); public List sourceTypes = new ArrayList<>(); diff --git a/shared/src/main/java/com/vaadin/shared/ui/PreloadMode.java b/shared/src/main/java/com/vaadin/shared/ui/PreloadMode.java new file mode 100644 index 0000000000..111278fb0c --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/PreloadMode.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.shared.ui; + +/** + * Enumeration that provides a hint to the browser how media should be + * preloaded. + * + * @since 7.7.11 + */ +public enum PreloadMode { + /** + * Indicates that the whole video/audio file could be downloaded, even if + * the user is not expected to use it. This is the default value. + */ + AUTO, + + /** + * Indicates that only media metadata (e.g. length) should be preloaded. + */ + METADATA, + + /** + * Indicates that the video/audio should not be preloaded. + */ + NONE; + + /** + * Returns the preload mode string used by the browser. + * + * @return corresponding preload attribute value string + */ + public String getValue() { + return name().toLowerCase(); + } +} -- cgit v1.2.3