diff --git a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLAudioElement.java b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLAudioElement.java new file mode 100644 index 000000000..e6007bef9 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLAudioElement.java @@ -0,0 +1,24 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.html; + +/** + * + * @author Junji Takakura + */ +public interface HTMLAudioElement extends HTMLMediaElement { + +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLMediaElement.java b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLMediaElement.java new file mode 100644 index 000000000..f7825ad8d --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLMediaElement.java @@ -0,0 +1,185 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.html; + +import java.util.Date; +import org.teavm.dom.media.AudioTrackList; +import org.teavm.dom.media.MediaController; +import org.teavm.dom.media.MediaError; +import org.teavm.dom.media.TextTrack; +import org.teavm.dom.media.TextTrackList; +import org.teavm.dom.media.TimeRanges; +import org.teavm.dom.media.VideoTrackList; +import org.teavm.jso.JSProperty; + +/** + * + * @author Junji Takakura + */ +public interface HTMLMediaElement extends HTMLElement { + + int HAVE_NOTHING = 0; + int HAVE_METADATA = 1; + int HAVE_CURRENT_DATA = 2; + int HAVE_FUTURE_DATA = 3; + int HAVE_ENOUGH_DATA = 4; + + int NETWORK_EMPTY = 0; + int NETWORK_IDLE = 1; + int NETWORK_LOADING = 2; + int NETWORK_NO_SOURCE = 3; + + @JSProperty + MediaError getError(); + + @JSProperty + String getSrc(); + + @JSProperty + void setSrc(String src); + + @JSProperty + String getCurrentSrc(); + + @JSProperty + String getCrossOrigin(); + + @JSProperty + void setCrossOrigin(String crossOrigin); + + @JSProperty + int getNetworkState(); + + @JSProperty + String getPreload(); + + @JSProperty + void setPreload(String preload); + + @JSProperty + TimeRanges getBuffered(); + + @JSProperty + int getReadyState(); + + @JSProperty + boolean isSeeking(); + + @JSProperty + double getCurrentTime(); + + @JSProperty + void setCurrentTime(double currentTime); + + @JSProperty + double getDuration(); + + @JSProperty + Date getStartDate(); + + @JSProperty + boolean isPaused(); + + @JSProperty + double getDefaultPlaybackRate(); + + @JSProperty + void setDefaultPlaybackRate(double defaultPlaybackRate); + + @JSProperty + double getPlaybackRate(); + + @JSProperty + void setPlaybackRate(double playbackRate); + + @JSProperty + TimeRanges getPlayed(); + + @JSProperty + TimeRanges getSeekable(); + + @JSProperty + boolean isEnded(); + + @JSProperty + boolean isAutoplay(); + + @JSProperty + void setAutoplay(boolean autoplay); + + @JSProperty + boolean isLoop(); + + @JSProperty + void setLoop(boolean loop); + + @JSProperty + String getMediaGroup(); + + @JSProperty + void setMediaGroup(String mediaGroup); + + @JSProperty + MediaController getController(); + + @JSProperty + void setController(MediaController controller); + + @JSProperty + boolean isControls(); + + @JSProperty + void setControls(boolean controls); + + @JSProperty + float getVolume(); + + @JSProperty + void setVolume(float volume); + + @JSProperty + boolean isMuted(); + + @JSProperty + void setMuted(boolean muted); + + @JSProperty + boolean isDefaultMuted(); + + @JSProperty + void setDefaultMuted(boolean defaultMuted); + + AudioTrackList getAudioTracks(); + + VideoTrackList getVideoTracks(); + + TextTrackList getTextTracks(); + + TextTrack addTextTrack(String kind); + + TextTrack addTextTrack(String kind, String label); + + TextTrack addTextTrack(String kind, String label, String language); + + void play(); + + void pause(); + + void load(); + + String canPlayType(String type); + +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLSourceElement.java b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLSourceElement.java new file mode 100644 index 000000000..bb2124b36 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLSourceElement.java @@ -0,0 +1,44 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.html; + +import org.teavm.jso.JSProperty; + +/** + * + * @author Junji Takakura + */ +public interface HTMLSourceElement extends HTMLElement { + + @JSProperty + String getType(); + + @JSProperty + void setType(String type); + + @JSProperty + String getSrc(); + + @JSProperty + void setSrc(String src); + + @JSProperty + String getMedia(); + + @JSProperty + void setMedia(String media); + +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLVideoElement.java b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLVideoElement.java new file mode 100644 index 000000000..53dbf1d94 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLVideoElement.java @@ -0,0 +1,49 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.html; + +import org.teavm.jso.JSProperty; + +/** + * + * @author Junji Takakura + */ +public interface HTMLVideoElement extends HTMLMediaElement { + + @JSProperty + int getWidth(); + + @JSProperty + int getHeight(); + + @JSProperty + void setWidth(int width); + + @JSProperty + void setHeight(int height); + + @JSProperty + int getVideoWidth(); + + @JSProperty + int getVideoHeight(); + + @JSProperty + String getPoster(); + + @JSProperty + void setPoster(String poster); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/media/AudioTrack.java b/teavm-dom/src/main/java/org/teavm/dom/media/AudioTrack.java new file mode 100644 index 000000000..7d9b28a1c --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/media/AudioTrack.java @@ -0,0 +1,44 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.media; + +import org.teavm.jso.JSObject; +import org.teavm.jso.JSProperty; + +/** + * + * @author Junji Takakura + */ +public interface AudioTrack extends JSObject { + + @JSProperty + String getId(); + + @JSProperty + String getLabel(); + + @JSProperty + String getKind(); + + @JSProperty + String getLanguage(); + + @JSProperty + boolean isEnabled(); + + @JSProperty + void setEnabled(boolean enabled); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/media/AudioTrackList.java b/teavm-dom/src/main/java/org/teavm/dom/media/AudioTrackList.java new file mode 100644 index 000000000..183da8c40 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/media/AudioTrackList.java @@ -0,0 +1,28 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.media; + +import org.teavm.dom.events.EventTarget; +import org.teavm.jso.JSArrayReader; + +/** + * + * @author Junji Takakura + */ +public interface AudioTrackList extends EventTarget, JSArrayReader { + + AudioTrack getTrackById(String id); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/media/MediaController.java b/teavm-dom/src/main/java/org/teavm/dom/media/MediaController.java new file mode 100644 index 000000000..6b4da6394 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/media/MediaController.java @@ -0,0 +1,81 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.media; + +import org.teavm.jso.JSObject; +import org.teavm.jso.JSProperty; + +/** + * + * @author Junji Takakura + */ +public interface MediaController extends JSObject { + + @JSProperty + TimeRanges getBuffered(); + + @JSProperty + double getCurrentTime(); + + @JSProperty + void setCurrentTime(double currentTime); + + @JSProperty + double getDefaultPlaybackRate(); + + @JSProperty + void setDefaultPlaybackRate(double defaultPlaybackRate); + + @JSProperty + double getDuration(); + + @JSProperty + boolean isMuted(); + + @JSProperty + void setMuted(boolean muted); + + @JSProperty + boolean isPaused(); + + @JSProperty + double getPlaybackRate(); + + @JSProperty + void setPlaybackRate(double playbackRate); + + @JSProperty + String getPlaybackState(); + + @JSProperty + TimeRanges getPlayed(); + + @JSProperty + int getReadyState(); + + @JSProperty + TimeRanges getSeekable(); + + @JSProperty + float getVolume(); + + @JSProperty + void setVolume(float volume); + + void play(); + + void pause(); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/media/MediaError.java b/teavm-dom/src/main/java/org/teavm/dom/media/MediaError.java new file mode 100644 index 000000000..a7d22b1a7 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/media/MediaError.java @@ -0,0 +1,34 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.media; + +import org.teavm.jso.JSObject; +import org.teavm.jso.JSProperty; + +/** + * + * @author Junji Takakura + */ +public interface MediaError extends JSObject { + + int MEDIA_ERR_ABORTED = 1; + int MEDIA_ERR_NETWORK = 2; + int MEDIA_ERR_DECODE = 3; + int MEDIA_ERR_SRC_NOT_SUPPORTED = 4; + + @JSProperty + int getCode(); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/media/TextTrack.java b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrack.java new file mode 100644 index 000000000..f34fedd30 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrack.java @@ -0,0 +1,58 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.media; + +import org.teavm.dom.events.EventTarget; +import org.teavm.jso.JSProperty; + +/** + * + * @author Junji Takakura + */ +public interface TextTrack extends EventTarget { + + String DISABLED = "disabled"; + String HIDDEN = "hidden"; + String SHOWING = "showing"; + + @JSProperty + String getId(); + + @JSProperty + String getLabel(); + + @JSProperty + String getKind(); + + @JSProperty + String getLanguage(); + + @JSProperty + String getMode(); + + @JSProperty + void setMode(String mode); + + @JSProperty + TextTrackCueList getCues(); + + @JSProperty + TextTrackCueList getActiveCues(); + + void addCue(TextTrackCue cue); + + void removeCue(TextTrackCue cue); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCue.java b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCue.java new file mode 100644 index 000000000..959b92ebf --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCue.java @@ -0,0 +1,98 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.media; + +import org.teavm.dom.core.DocumentFragment; +import org.teavm.dom.events.EventTarget; +import org.teavm.jso.JSProperty; + +/** + * + * @author Junji Takakura + */ +public interface TextTrackCue extends EventTarget { + + @JSProperty + TextTrack getTrack(); + + @JSProperty + String getId(); + + @JSProperty + void setId(String id); + + @JSProperty + double getStartTime(); + + @JSProperty + void setStartTime(double startTime); + + @JSProperty + double getEndTime(); + + @JSProperty + void setEndTime(double endTime); + + @JSProperty + boolean isPauseOnExit(); + + @JSProperty + void setPauseOnExit(boolean pauseOnExit); + + @JSProperty + String getVertical(); + + @JSProperty + void setVertical(String vertical); + + @JSProperty + boolean isSnapToLines(); + + @JSProperty + void setSnapToLines(boolean snapToLines); + + @JSProperty + int getLine(); + + @JSProperty + void setLine(int line); + + @JSProperty + int getPosition(); + + @JSProperty + void setPosition(int position); + + @JSProperty + int getSize(); + + @JSProperty + void setSize(int size); + + @JSProperty + String getAlign(); + + @JSProperty + void setAlign(String align); + + @JSProperty + String getText(); + + @JSProperty + void setText(String text); + + DocumentFragment getCueAsHTML(); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCueList.java b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCueList.java new file mode 100644 index 000000000..f3becb0be --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCueList.java @@ -0,0 +1,28 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.media; + +import org.teavm.jso.JSArrayReader; +import org.teavm.jso.JSObject; + +/** + * + * @author Junji Takakura + */ +public interface TextTrackCueList extends JSObject, JSArrayReader { + + TextTrackCue getCueById(String id); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackList.java b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackList.java new file mode 100644 index 000000000..08ae391df --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackList.java @@ -0,0 +1,28 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.media; + +import org.teavm.dom.events.EventTarget; +import org.teavm.jso.JSArrayReader; + +/** + * + * @author Junji Takakura + */ +public interface TextTrackList extends EventTarget, JSArrayReader { + + TextTrack getTrackById(String id); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/media/TimeRanges.java b/teavm-dom/src/main/java/org/teavm/dom/media/TimeRanges.java new file mode 100644 index 000000000..4b032f235 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/media/TimeRanges.java @@ -0,0 +1,33 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.media; + +import org.teavm.jso.JSObject; +import org.teavm.jso.JSProperty; + +/** + * + * @author Junji Takakura + */ +public interface TimeRanges extends JSObject { + + @JSProperty + int getLength(); + + float start(int index); + + float end(int index); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/media/VideoTrack.java b/teavm-dom/src/main/java/org/teavm/dom/media/VideoTrack.java new file mode 100644 index 000000000..4eb574bee --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/media/VideoTrack.java @@ -0,0 +1,44 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.media; + +import org.teavm.jso.JSObject; +import org.teavm.jso.JSProperty; + +/** + * + * @author Junji Takakura + */ +public interface VideoTrack extends JSObject { + + @JSProperty + String getId(); + + @JSProperty + String getLabel(); + + @JSProperty + String getKind(); + + @JSProperty + String getLanguage(); + + @JSProperty + boolean isSelected(); + + @JSProperty + void setSelected(boolean selected); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/media/VideoTrackList.java b/teavm-dom/src/main/java/org/teavm/dom/media/VideoTrackList.java new file mode 100644 index 000000000..fa3ead641 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/media/VideoTrackList.java @@ -0,0 +1,32 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.dom.media; + +import org.teavm.dom.events.EventTarget; +import org.teavm.jso.JSArrayReader; +import org.teavm.jso.JSProperty; + +/** + * + * @author Junji Takakura + */ +public interface VideoTrackList extends EventTarget, JSArrayReader { + + @JSProperty + int getSelectedIndex(); + + VideoTrack getTrackById(String id); +} diff --git a/teavm-samples/pom.xml b/teavm-samples/pom.xml index 6795fb884..bcc56b08c 100644 --- a/teavm-samples/pom.xml +++ b/teavm-samples/pom.xml @@ -33,5 +33,6 @@ teavm-samples-hello teavm-samples-benchmark teavm-samples-storage + teavm-samples-video \ No newline at end of file diff --git a/teavm-samples/teavm-samples-video/pom.xml b/teavm-samples/teavm-samples-video/pom.xml new file mode 100644 index 000000000..351969f11 --- /dev/null +++ b/teavm-samples/teavm-samples-video/pom.xml @@ -0,0 +1,110 @@ + + + 4.0.0 + + + org.teavm + teavm-samples + 0.3.0-SNAPSHOT + + teavm-samples-video + + war + + TeaVM HTML5 video web application + A sample application that shows HTML5 video implementation for TeaVM + + + + org.teavm + teavm-classlib + ${project.version} + + + org.teavm + teavm-jso + ${project.version} + + + org.teavm + teavm-dom + ${project.version} + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + + + + + maven-war-plugin + 2.4 + + + + ${project.build.directory}/generated/js + + + + + + org.teavm + teavm-maven-plugin + ${project.version} + + + web-client + prepare-package + + build-javascript + + + ${project.build.directory}/generated/js/teavm + org.teavm.samples.video.Player + SEPARATE + false + true + true + true + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + ../../checkstyle.xml + config_loc=${basedir}/../.. + + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + \ No newline at end of file diff --git a/teavm-samples/teavm-samples-video/src/main/java/org/teavm/samples/video/Player.java b/teavm-samples/teavm-samples-video/src/main/java/org/teavm/samples/video/Player.java new file mode 100644 index 000000000..f6e3a45cd --- /dev/null +++ b/teavm-samples/teavm-samples-video/src/main/java/org/teavm/samples/video/Player.java @@ -0,0 +1,221 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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 org.teavm.samples.video; + +import org.teavm.dom.browser.Window; +import org.teavm.dom.events.Event; +import org.teavm.dom.events.EventListener; +import org.teavm.dom.html.HTMLBodyElement; +import org.teavm.dom.html.HTMLButtonElement; +import org.teavm.dom.html.HTMLDocument; +import org.teavm.dom.html.HTMLElement; +import org.teavm.dom.html.HTMLSourceElement; +import org.teavm.dom.html.HTMLVideoElement; +import org.teavm.jso.JS; + +public final class Player { + + private static Window window = (Window)JS.getGlobal(); + private static HTMLDocument document = window.getDocument(); + + private Player() { + } + + public static void main(String[] args) { + HTMLSourceElement sourceMp4 = (HTMLSourceElement)document.createElement("source"); + sourceMp4.setAttribute("id", "mp4"); + sourceMp4.setSrc("http://media.w3.org/2010/05/sintel/trailer.mp4"); + sourceMp4.setAttribute("type", "video/mp4"); + + HTMLSourceElement sourceWebm = (HTMLSourceElement)document.createElement("source"); + sourceWebm.setAttribute("id", "webm"); + sourceWebm.setSrc("http://media.w3.org/2010/05/sintel/trailer.webm"); + sourceWebm.setAttribute("type", "video/webm"); + + HTMLSourceElement sourceOgv = (HTMLSourceElement)document.createElement("source"); + sourceOgv.setAttribute("id", "ogv"); + sourceOgv.setSrc("http://media.w3.org/2010/05/sintel/trailer.ogv"); + sourceOgv.setAttribute("type", "video/ogg"); + + HTMLElement p = document.createElement("p"); + p.appendChild(document.createTextNode("Your user agent does not support the HTML5 Video element.")); + + final HTMLVideoElement video = (HTMLVideoElement)document.createElement("video"); + video.setAttribute("id", "video"); + video.setControls(true); + video.setPreload("none"); + video.setMediaGroup("myVideoGroup"); + video.setPoster("http://media.w3.org/2010/05/sintel/poster.png"); + video.appendChild(sourceMp4); + video.appendChild(sourceWebm); + video.appendChild(sourceOgv); + video.appendChild(p); + + HTMLElement divVideo = document.createElement("div"); + divVideo.appendChild(video); + + HTMLButtonElement loadButton = (HTMLButtonElement)document.createElement("button"); + loadButton.appendChild(document.createTextNode("load()")); + loadButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.load(); + } + }); + + HTMLButtonElement playButton = (HTMLButtonElement)document.createElement("button"); + playButton.appendChild(document.createTextNode("play()")); + playButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.play(); + } + }); + + HTMLButtonElement pauseButton = (HTMLButtonElement)document.createElement("button"); + pauseButton.appendChild(document.createTextNode("pause()")); + pauseButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.pause(); + } + }); + + HTMLButtonElement currentTimePlusButton = (HTMLButtonElement)document.createElement("button"); + currentTimePlusButton.appendChild(document.createTextNode("currentTime+=10")); + currentTimePlusButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.setCurrentTime(video.getCurrentTime() + 10); + } + }); + + HTMLButtonElement currentTimeMinusButton = (HTMLButtonElement)document.createElement("button"); + currentTimeMinusButton.appendChild(document.createTextNode("currentTime-=10")); + currentTimeMinusButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.setCurrentTime(video.getCurrentTime() - 10); + } + }); + + HTMLButtonElement currentTime50Button = (HTMLButtonElement)document.createElement("button"); + currentTime50Button.appendChild(document.createTextNode("currentTime=50")); + currentTime50Button.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.setCurrentTime(50); + } + }); + + HTMLButtonElement playbackRateIncrementButton = (HTMLButtonElement)document.createElement("button"); + playbackRateIncrementButton.appendChild(document.createTextNode("playbackRate++")); + playbackRateIncrementButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.setPlaybackRate(video.getPlaybackRate() + 1); + } + }); + + HTMLButtonElement playbackRateDecrementButton = (HTMLButtonElement)document.createElement("button"); + playbackRateDecrementButton.appendChild(document.createTextNode("playbackRate--")); + playbackRateDecrementButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.setPlaybackRate(video.getPlaybackRate() - 1); + } + }); + + HTMLButtonElement playbackRatePlusButton = (HTMLButtonElement)document.createElement("button"); + playbackRatePlusButton.appendChild(document.createTextNode("playbackRate+=0.1")); + playbackRatePlusButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.setPlaybackRate(video.getPlaybackRate() + 0.1); + } + }); + + HTMLButtonElement playbackRateMinusButton = (HTMLButtonElement)document.createElement("button"); + playbackRateMinusButton.appendChild(document.createTextNode("playbackRate-=0.1")); + playbackRateMinusButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.setPlaybackRate(video.getPlaybackRate() - 0.1); + } + }); + + HTMLButtonElement volumePlusButton = (HTMLButtonElement)document.createElement("button"); + volumePlusButton.appendChild(document.createTextNode("volume+=0.1")); + volumePlusButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.setVolume(video.getVolume() + 0.1f); + } + }); + + HTMLButtonElement volumeMinusButton = (HTMLButtonElement)document.createElement("button"); + volumeMinusButton.appendChild(document.createTextNode("volume-=0.1")); + volumeMinusButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.setVolume(video.getVolume() - 0.1f); + } + }); + + HTMLButtonElement muteButton = (HTMLButtonElement)document.createElement("button"); + muteButton.appendChild(document.createTextNode("muted=true")); + muteButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.setMuted(true); + } + }); + + HTMLButtonElement unmuteButton = (HTMLButtonElement)document.createElement("button"); + unmuteButton.appendChild(document.createTextNode("muted=false")); + unmuteButton.addEventListener("click", new EventListener() { + @Override + public void handleEvent(Event evt) { + video.setMuted(false); + } + }); + + HTMLElement divButtons = document.createElement("div"); + divButtons.setAttribute("id", "buttons"); + divButtons.appendChild(loadButton); + divButtons.appendChild(playButton); + divButtons.appendChild(pauseButton); + divButtons.appendChild(document.createElement("br")); + divButtons.appendChild(currentTimePlusButton); + divButtons.appendChild(currentTimeMinusButton); + divButtons.appendChild(currentTime50Button); + divButtons.appendChild(document.createElement("br")); + divButtons.appendChild(playbackRateIncrementButton); + divButtons.appendChild(playbackRateDecrementButton); + divButtons.appendChild(playbackRatePlusButton); + divButtons.appendChild(playbackRateMinusButton); + divButtons.appendChild(document.createElement("br")); + divButtons.appendChild(volumePlusButton); + divButtons.appendChild(volumeMinusButton); + divButtons.appendChild(muteButton); + divButtons.appendChild(unmuteButton); + + HTMLBodyElement body = document.getBody(); + body.appendChild(divVideo); + body.appendChild(divButtons); + } + +} diff --git a/teavm-samples/teavm-samples-video/src/main/webapp/WEB-INF/web.xml b/teavm-samples/teavm-samples-video/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..6471cd77a --- /dev/null +++ b/teavm-samples/teavm-samples-video/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/teavm-samples/teavm-samples-video/src/main/webapp/index.html b/teavm-samples/teavm-samples-video/src/main/webapp/index.html new file mode 100644 index 000000000..e9740a3fe --- /dev/null +++ b/teavm-samples/teavm-samples-video/src/main/webapp/index.html @@ -0,0 +1,28 @@ + + + + + HTML5 Video web application + + + + + + +

HTML5 Video web application

+ + \ No newline at end of file diff --git a/teavm-samples/teavm-samples-video/src/main/webapp/style.css b/teavm-samples/teavm-samples-video/src/main/webapp/style.css new file mode 100644 index 000000000..d84ba0e5b --- /dev/null +++ b/teavm-samples/teavm-samples-video/src/main/webapp/style.css @@ -0,0 +1,12 @@ +video { + border: 1px solid black; + padding: 0; margin: 0; + width: 427px; + height: 240px; + background-color: black; + margin: auto; + float: left; +} +#buttons { + text-align: center; +} \ No newline at end of file