From 0206ea4e0a03ff82ea6848225622826c52df7c06 Mon Sep 17 00:00:00 2001
From: Junji Takakura <j.takakura@gmail.com>
Date: Wed, 21 Jan 2015 09:48:45 +0900
Subject: [PATCH 1/4] Adds implementation of HTMLMediaElement,
 HTMLVideoElement, HTMLAudioElement and HTMLSourceElement

---
 .../org/teavm/dom/html/HTMLAudioElement.java  |  24 +++
 .../org/teavm/dom/html/HTMLMediaElement.java  | 180 ++++++++++++++++++
 .../org/teavm/dom/html/HTMLSourceElement.java |  44 +++++
 .../org/teavm/dom/html/HTMLVideoElement.java  |  52 +++++
 .../java/org/teavm/dom/media/AudioTrack.java  |  43 +++++
 .../org/teavm/dom/media/AudioTrackList.java   |  31 +++
 .../org/teavm/dom/media/MediaController.java  |  83 ++++++++
 .../java/org/teavm/dom/media/MediaError.java  |  34 ++++
 .../java/org/teavm/dom/media/TextTrack.java   |  63 ++++++
 .../org/teavm/dom/media/TextTrackCue.java     |  44 +++++
 .../org/teavm/dom/media/TextTrackCueList.java |  33 ++++
 .../org/teavm/dom/media/TextTrackList.java    |  33 ++++
 .../java/org/teavm/dom/media/TimeRanges.java  |  33 ++++
 .../java/org/teavm/dom/media/VideoTrack.java  |  43 +++++
 .../org/teavm/dom/media/VideoTrackList.java   |  36 ++++
 15 files changed, 776 insertions(+)
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/html/HTMLAudioElement.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/html/HTMLMediaElement.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/html/HTMLSourceElement.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/html/HTMLVideoElement.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/media/AudioTrack.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/media/AudioTrackList.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/media/MediaController.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/media/MediaError.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/media/TextTrack.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCue.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCueList.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/media/TextTrackList.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/media/TimeRanges.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/media/VideoTrack.java
 create mode 100644 teavm-dom/src/main/java/org/teavm/dom/media/VideoTrackList.java

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..d71e34209
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLAudioElement.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2015 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..e3df3e8d8
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLMediaElement.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2015 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.dom.media.VideoTrackList;
+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.jso.JSProperty;
+
+/**
+ *
+ * @author Junji Takakura
+ */
+public interface HTMLMediaElement extends HTMLElement {
+
+    public static final int HAVE_NOTHING = 0;
+    public static final int HAVE_METADATA = 1;
+    public static final int HAVE_CURRENT_DATA = 2;
+    public static final int HAVE_FUTURE_DATA = 3;
+    public static final int HAVE_ENOUGH_DATA = 4;
+
+    public static final int NETWORK_EMPTY = 0;
+    public static final int NETWORK_IDLE = 1;
+    public static final int NETWORK_LOADING = 2;
+    public static final int NETWORK_NO_SOURCE = 3;
+
+    @JSProperty
+    MediaError getError();
+
+    @JSProperty
+    String getSrc();
+
+    @JSProperty
+    void setSrc(String src);
+
+    @JSProperty
+    String getCurrentSrc();
+
+    @JSProperty
+    void setCurrentSrc(String currentSrc);
+
+    @JSProperty
+    String getCrossOrigin();
+
+    @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 getStartOffsetTime();
+
+    @JSProperty
+    boolean getPaused();
+
+    @JSProperty
+    double getDefaultPlaybackRate();
+
+    @JSProperty
+    void setDefaultPlaybackRate(double defaultPlaybackRate);
+
+    @JSProperty
+    double getPlaybackRate();
+
+    @JSProperty
+    void setPlaybackRate(double playbackRate);
+
+    @JSProperty
+    TimeRanges getPlayed();
+
+    @JSProperty
+    TimeRanges getSeekable();
+
+    @JSProperty
+    boolean getEnded();
+
+    @JSProperty
+    boolean isAutoplay();
+
+    @JSProperty
+    void setAutoplay(boolean autoplay);
+    
+    boolean isLoop();
+    
+    void setLoop(boolean loop);
+    
+    @JSProperty
+    String getMediaGroup();
+
+    @JSProperty
+    MediaController getController();
+
+    @JSProperty
+    void setController(MediaController controller);    
+
+    @JSProperty
+    boolean getControlls();
+
+    @JSProperty
+    void setControlls(boolean controlls);
+
+    @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..8009c8794
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLSourceElement.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2015 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..94670612f
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLVideoElement.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2015 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
+    void setWidth(int width);
+
+    @JSProperty
+    int getHeight();
+
+    @JSProperty
+    void setHeight(int height);
+
+    @JSProperty
+    int getVideoWidth();
+
+    @JSProperty
+    void setVideoWidth(int videoWidth);
+
+    @JSProperty
+    int getVideoHeight();
+
+    @JSProperty
+    void setVideoHeight(int videoHeight);
+
+    @JSProperty
+    String getPoster();
+}
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..bab464715
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/AudioTrack.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2015 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.JSProperty;
+
+/**
+ *
+ * @author Junji Takakura
+ */
+public interface AudioTrack {
+
+    @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..054709595
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/AudioTrackList.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2015 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 AudioTrackList extends EventTarget {
+    @JSProperty
+    int getLength();
+    
+    AudioTrack item(int index);
+    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..b1127d35a
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/MediaController.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2015 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();
+
+    void unpause();
+}
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..704b4c707
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/MediaError.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2015 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 {
+
+    public static final int MEDIA_ERR_ABORTED = 1;
+    public static final int MEDIA_ERR_NETWORK = 2;
+    public static final int MEDIA_ERR_DECODE = 3;
+    public static final 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..ddccc8fc8
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrack.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2015 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.JSProperty;
+
+/**
+ *
+ * @author Junji Takakura
+ */
+public interface TextTrack {
+
+    public static final String DISABLED = "disabled";
+    public static final String HIDDEN = "hidden";
+    public static final String SHOWING = "showing";
+
+    @JSProperty
+    String getId();
+
+    @JSProperty
+    String getLabel();
+
+    @JSProperty
+    String getKind();
+
+    @JSProperty
+    String getLanguage();
+
+    @JSProperty
+    String getMode();
+
+    @JSProperty
+    void setMode(String mode);
+
+    @JSProperty
+    boolean isEnabled();
+
+    @JSProperty
+    void setEnabled(boolean enabled);
+
+    @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..8bd4b05ab
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCue.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2015 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 TextTrackCue extends EventTarget {
+
+    @JSProperty
+    String getId();
+
+    @JSProperty
+    double getStartTime();
+
+    @JSProperty
+    double getEndTime();
+
+    @JSProperty
+    boolean isPauseOnExit();
+
+    @JSProperty
+    String getText();
+
+    @JSProperty
+    TextTrack getTrack();
+}
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..72e0b36b0
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCueList.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2015 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 TextTrackCueList extends JSObject {
+
+    @JSProperty
+    int getLength();
+
+    TextTrackCue item(int index);
+
+    TextTrackCue getTrackById(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..f625e66f0
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackList.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2015 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 TextTrackList extends EventTarget {
+
+    @JSProperty
+    int getLength();
+
+    TextTrack item(int index);
+
+    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..c0dd0594d
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/TimeRanges.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2015 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..199d26ffc
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/VideoTrack.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2015 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.JSProperty;
+
+/**
+ *
+ * @author Junji Takakura
+ */
+public interface VideoTrack {
+
+    @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..232712304
--- /dev/null
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/VideoTrackList.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2015 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 VideoTrackList extends EventTarget {
+
+    @JSProperty
+    int getLength();
+
+    @JSProperty
+    int getSelectedIndex();
+
+    VideoTrack item(int index);
+
+    VideoTrack getTrackById(String id);
+}

From ec4e4a97711f850fe3f976bde148d8aadaf2a1e6 Mon Sep 17 00:00:00 2001
From: Junji Takakura <j.takakura@gmail.com>
Date: Sat, 24 Jan 2015 17:28:24 +0900
Subject: [PATCH 2/4] Fix bugs

---
 .../org/teavm/dom/html/HTMLMediaElement.java  | 53 +++++++------
 .../org/teavm/dom/html/HTMLVideoElement.java  | 13 ++--
 .../java/org/teavm/dom/media/AudioTrack.java  | 23 +++---
 .../org/teavm/dom/media/AudioTrackList.java   | 29 ++++---
 .../org/teavm/dom/media/MediaController.java  | 22 +++---
 .../java/org/teavm/dom/media/MediaError.java  | 28 +++----
 .../java/org/teavm/dom/media/TextTrack.java   | 35 ++++-----
 .../org/teavm/dom/media/TextTrackCue.java     | 76 ++++++++++++++++---
 .../org/teavm/dom/media/TextTrackCueList.java | 31 ++++----
 .../org/teavm/dom/media/TextTrackList.java    | 29 +++----
 .../java/org/teavm/dom/media/TimeRanges.java  | 20 ++---
 .../java/org/teavm/dom/media/VideoTrack.java  | 23 +++---
 .../org/teavm/dom/media/VideoTrackList.java   | 28 +++----
 13 files changed, 222 insertions(+), 188 deletions(-)

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
index e3df3e8d8..fb67616bc 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLMediaElement.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLMediaElement.java
@@ -31,16 +31,16 @@ import org.teavm.jso.JSProperty;
  */
 public interface HTMLMediaElement extends HTMLElement {
 
-    public static final int HAVE_NOTHING = 0;
-    public static final int HAVE_METADATA = 1;
-    public static final int HAVE_CURRENT_DATA = 2;
-    public static final int HAVE_FUTURE_DATA = 3;
-    public static final int HAVE_ENOUGH_DATA = 4;
+    int HAVE_NOTHING = 0;
+    int HAVE_METADATA = 1;
+    int HAVE_CURRENT_DATA = 2;
+    int HAVE_FUTURE_DATA = 3;
+    int HAVE_ENOUGH_DATA = 4;
 
-    public static final int NETWORK_EMPTY = 0;
-    public static final int NETWORK_IDLE = 1;
-    public static final int NETWORK_LOADING = 2;
-    public static final int NETWORK_NO_SOURCE = 3;
+    int NETWORK_EMPTY = 0;
+    int NETWORK_IDLE = 1;
+    int NETWORK_LOADING = 2;
+    int NETWORK_NO_SOURCE = 3;
 
     @JSProperty
     MediaError getError();
@@ -55,10 +55,10 @@ public interface HTMLMediaElement extends HTMLElement {
     String getCurrentSrc();
 
     @JSProperty
-    void setCurrentSrc(String currentSrc);
+    String getCrossOrigin();
 
     @JSProperty
-    String getCrossOrigin();
+    void setCrossOrigin(String crossOrigin);
 
     @JSProperty
     int getNetworkState();
@@ -88,10 +88,10 @@ public interface HTMLMediaElement extends HTMLElement {
     double getDuration();
 
     @JSProperty
-    Date getStartOffsetTime();
+    Date getStartDate();
 
     @JSProperty
-    boolean getPaused();
+    boolean isPaused();
 
     @JSProperty
     double getDefaultPlaybackRate();
@@ -112,38 +112,43 @@ public interface HTMLMediaElement extends HTMLElement {
     TimeRanges getSeekable();
 
     @JSProperty
-    boolean getEnded();
+    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);    
+    void setController(MediaController controller);
 
     @JSProperty
-    boolean getControlls();
+    boolean isControls();
 
     @JSProperty
-    void setControlls(boolean controlls);
+    void setControls(boolean controls);
 
     @JSProperty
     float getVolume();
 
     @JSProperty
-    void setVolume(float volume);    
+    void setVolume(float volume);
 
     @JSProperty
     boolean isMuted();
@@ -156,11 +161,11 @@ public interface HTMLMediaElement extends HTMLElement {
 
     @JSProperty
     void setDefaultMuted(boolean defaultMuted);
-    
+
     AudioTrackList getAudioTracks();
-    
+
     VideoTrackList getVideoTracks();
-    
+
     TextTrackList getTextTracks();
 
     TextTrack addTextTrack(String kind);
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
index 94670612f..4606cdbef 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLVideoElement.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLVideoElement.java
@@ -27,10 +27,10 @@ public interface HTMLVideoElement extends HTMLMediaElement {
     int getWidth();
 
     @JSProperty
-    void setWidth(int width);
+    int getHeight();
 
     @JSProperty
-    int getHeight();
+    void setWidth(int width);
 
     @JSProperty
     void setHeight(int height);
@@ -38,15 +38,12 @@ public interface HTMLVideoElement extends HTMLMediaElement {
     @JSProperty
     int getVideoWidth();
 
-    @JSProperty
-    void setVideoWidth(int videoWidth);
-
     @JSProperty
     int getVideoHeight();
 
-    @JSProperty
-    void setVideoHeight(int videoHeight);
-
     @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
index bab464715..7d9b28a1c 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/media/AudioTrack.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/AudioTrack.java
@@ -1,27 +1,28 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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 {
+public interface AudioTrack extends JSObject {
 
     @JSProperty
     String getId();
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
index 054709595..183da8c40 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/media/AudioTrackList.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/AudioTrackList.java
@@ -1,31 +1,28 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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;
+import org.teavm.jso.JSArrayReader;
 
 /**
  *
  * @author Junji Takakura
  */
-public interface AudioTrackList extends EventTarget {
-    @JSProperty
-    int getLength();
-    
-    AudioTrack item(int index);
+public interface AudioTrackList extends EventTarget, JSArrayReader<AudioTrack> {
+
     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
index b1127d35a..6b4da6394 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/media/MediaController.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/MediaController.java
@@ -1,17 +1,17 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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;
 
@@ -78,6 +78,4 @@ public interface MediaController extends JSObject {
     void play();
 
     void pause();
-
-    void unpause();
 }
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
index 704b4c707..a7d22b1a7 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/media/MediaError.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/MediaError.java
@@ -1,17 +1,17 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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;
 
@@ -24,10 +24,10 @@ import org.teavm.jso.JSProperty;
  */
 public interface MediaError extends JSObject {
 
-    public static final int MEDIA_ERR_ABORTED = 1;
-    public static final int MEDIA_ERR_NETWORK = 2;
-    public static final int MEDIA_ERR_DECODE = 3;
-    public static final int MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
+    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
index ddccc8fc8..f34fedd30 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/media/TextTrack.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrack.java
@@ -1,31 +1,32 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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 {
+public interface TextTrack extends EventTarget {
 
-    public static final String DISABLED = "disabled";
-    public static final String HIDDEN = "hidden";
-    public static final String SHOWING = "showing";
+    String DISABLED = "disabled";
+    String HIDDEN = "hidden";
+    String SHOWING = "showing";
 
     @JSProperty
     String getId();
@@ -45,12 +46,6 @@ public interface TextTrack {
     @JSProperty
     void setMode(String mode);
 
-    @JSProperty
-    boolean isEnabled();
-
-    @JSProperty
-    void setEnabled(boolean enabled);
-
     @JSProperty
     TextTrackCueList getCues();
 
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
index 8bd4b05ab..959b92ebf 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCue.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCue.java
@@ -1,20 +1,21 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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;
 
@@ -24,21 +25,74 @@ import org.teavm.jso.JSProperty;
  */
 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
-    TextTrack getTrack();
+    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
index 72e0b36b0..f3becb0be 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCueList.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackCueList.java
@@ -1,33 +1,28 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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;
-import org.teavm.jso.JSProperty;
 
 /**
  *
  * @author Junji Takakura
  */
-public interface TextTrackCueList extends JSObject {
+public interface TextTrackCueList extends JSObject, JSArrayReader<TextTrackCue> {
 
-    @JSProperty
-    int getLength();
-
-    TextTrackCue item(int index);
-
-    TextTrackCue getTrackById(String id);
+    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
index f625e66f0..08ae391df 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackList.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/TextTrackList.java
@@ -1,33 +1,28 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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;
+import org.teavm.jso.JSArrayReader;
 
 /**
  *
  * @author Junji Takakura
  */
-public interface TextTrackList extends EventTarget {
-
-    @JSProperty
-    int getLength();
-
-    TextTrack item(int index);
+public interface TextTrackList extends EventTarget, JSArrayReader<TextTrack> {
 
     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
index c0dd0594d..4b032f235 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/media/TimeRanges.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/TimeRanges.java
@@ -1,17 +1,17 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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;
 
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
index 199d26ffc..4eb574bee 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/media/VideoTrack.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/VideoTrack.java
@@ -1,27 +1,28 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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 {
+public interface VideoTrack extends JSObject {
 
     @JSProperty
     String getId();
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
index 232712304..fa3ead641 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/media/VideoTrackList.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/media/VideoTrackList.java
@@ -1,36 +1,32 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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 {
-
-    @JSProperty
-    int getLength();
+public interface VideoTrackList extends EventTarget, JSArrayReader<VideoTrack> {
 
     @JSProperty
     int getSelectedIndex();
 
-    VideoTrack item(int index);
-
     VideoTrack getTrackById(String id);
 }

From 14a6c099d9aceff453e8f1d60a1821f5936b84b0 Mon Sep 17 00:00:00 2001
From: Junji Takakura <j.takakura@gmail.com>
Date: Sat, 24 Jan 2015 20:00:01 +0900
Subject: [PATCH 3/4] Adds HTML5 Video Demo Application

---
 teavm-samples/pom.xml                         |   1 +
 teavm-samples/teavm-samples-video/pom.xml     | 110 +++++++++
 .../java/org/teavm/samples/video/Player.java  | 221 ++++++++++++++++++
 .../src/main/webapp/WEB-INF/web.xml           |  21 ++
 .../src/main/webapp/index.html                |  28 +++
 .../src/main/webapp/style.css                 |  12 +
 6 files changed, 393 insertions(+)
 create mode 100644 teavm-samples/teavm-samples-video/pom.xml
 create mode 100644 teavm-samples/teavm-samples-video/src/main/java/org/teavm/samples/video/Player.java
 create mode 100644 teavm-samples/teavm-samples-video/src/main/webapp/WEB-INF/web.xml
 create mode 100644 teavm-samples/teavm-samples-video/src/main/webapp/index.html
 create mode 100644 teavm-samples/teavm-samples-video/src/main/webapp/style.css

diff --git a/teavm-samples/pom.xml b/teavm-samples/pom.xml
index 1b9dc40c4..4bef2c0be 100644
--- a/teavm-samples/pom.xml
+++ b/teavm-samples/pom.xml
@@ -32,5 +32,6 @@
   <modules>
     <module>teavm-samples-hello</module>
     <module>teavm-samples-benchmark</module>
+    <module>teavm-samples-video</module>
   </modules>
 </project>
\ 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 @@
+<!--
+    Copyright 2015 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.teavm</groupId>
+    <artifactId>teavm-samples</artifactId>
+    <version>0.3.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>teavm-samples-video</artifactId>
+
+  <packaging>war</packaging>
+
+  <name>TeaVM HTML5 video web application</name>
+  <description>A sample application that shows HTML5 video implementation for TeaVM</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.teavm</groupId>
+      <artifactId>teavm-classlib</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.teavm</groupId>
+      <artifactId>teavm-jso</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.teavm</groupId>
+      <artifactId>teavm-dom</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>javax.servlet-api</artifactId>
+      <version>3.1.0</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-war-plugin</artifactId>
+        <version>2.4</version>
+        <configuration>
+          <webResources>
+            <resource>
+              <directory>${project.build.directory}/generated/js</directory>
+            </resource>
+          </webResources>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.teavm</groupId>
+        <artifactId>teavm-maven-plugin</artifactId>
+        <version>${project.version}</version>
+        <executions>
+          <execution>
+            <id>web-client</id>
+            <phase>prepare-package</phase>
+            <goals>
+              <goal>build-javascript</goal>
+            </goals>
+            <configuration>
+              <targetDirectory>${project.build.directory}/generated/js/teavm</targetDirectory>
+              <mainClass>org.teavm.samples.video.Player</mainClass>
+              <runtime>SEPARATE</runtime>
+              <minifying>false</minifying>
+              <debugInformationGenerated>true</debugInformationGenerated>
+              <sourceMapsGenerated>true</sourceMapsGenerated>
+              <sourceFilesCopied>true</sourceFilesCopied>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <configLocation>../../checkstyle.xml</configLocation>
+          <propertyExpansion>config_loc=${basedir}/../..</propertyExpansion>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ 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..c8a90d60c
--- /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.getController().setCurrentTime(video.getController().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.getController().setCurrentTime(video.getController().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.getController().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.getController().setPlaybackRate(video.getController().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.getController().setPlaybackRate(video.getController().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.getController().setPlaybackRate(video.getController().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.getController().setPlaybackRate(video.getController().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.getController().setVolume(video.getController().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.getController().setVolume(video.getController().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.getController().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.getController().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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Copyright 2015 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.
+-->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+      version="3.0">
+</web-app>
\ 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 @@
+<!--
+    Copyright 2015 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.
+-->
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>HTML5 Video web application</title>
+    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+    <script type="text/javascript" charset="utf-8" src="teavm/runtime.js"></script>
+    <script type="text/javascript" charset="utf-8" src="teavm/classes.js"></script>
+    <link href="style.css" rel="stylesheet" type="text/css">
+  </head>
+  <body onload="main()">
+    <h1>HTML5 Video web application</h1>
+  </body>
+</html>
\ 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

From 2e98e1f61a6a0a2a260d5816c2aaa8a9ab5ebf23 Mon Sep 17 00:00:00 2001
From: Junji Takakura <j.takakura@gmail.com>
Date: Sat, 24 Jan 2015 21:56:29 +0900
Subject: [PATCH 4/4] Fix Checkstyle errors

---
 .../org/teavm/dom/html/HTMLAudioElement.java  | 20 ++++++++---------
 .../org/teavm/dom/html/HTMLMediaElement.java  | 22 +++++++++----------
 .../org/teavm/dom/html/HTMLSourceElement.java | 20 ++++++++---------
 .../org/teavm/dom/html/HTMLVideoElement.java  | 22 +++++++++----------
 4 files changed, 42 insertions(+), 42 deletions(-)

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
index d71e34209..e6007bef9 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLAudioElement.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLAudioElement.java
@@ -1,17 +1,17 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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;
 
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
index fb67616bc..f7825ad8d 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLMediaElement.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLMediaElement.java
@@ -1,21 +1,20 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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.dom.media.VideoTrackList;
 import java.util.Date;
 import org.teavm.dom.media.AudioTrackList;
 import org.teavm.dom.media.MediaController;
@@ -23,6 +22,7 @@ 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;
 
 /**
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
index 8009c8794..bb2124b36 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLSourceElement.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLSourceElement.java
@@ -1,17 +1,17 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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;
 
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
index 4606cdbef..53dbf1d94 100644
--- a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLVideoElement.java
+++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLVideoElement.java
@@ -1,17 +1,17 @@
 /*
- * Copyright 2015 Alexey Andreev.
+ *  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
+ *  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
+ *       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.
+ *  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;
 
@@ -43,7 +43,7 @@ public interface HTMLVideoElement extends HTMLMediaElement {
 
     @JSProperty
     String getPoster();
-    
+
     @JSProperty
     void setPoster(String poster);
 }