Adds implementation of HTMLMediaElement, HTMLVideoElement, HTMLAudioElement and HTMLSourceElement

This commit is contained in:
Junji Takakura 2015-01-21 09:48:45 +09:00
parent 7d2e323af0
commit 0206ea4e0a
15 changed files with 776 additions and 0 deletions

View File

@ -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 {
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}