mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Merge branch 'implements-html-media-element' of
https://github.com/jtakakura/teavm into jtakakura-implements-html-media-element Conflicts: teavm-samples/pom.xml
This commit is contained in:
commit
7fb5c32c9b
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.html;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface HTMLAudioElement extends HTMLMediaElement {
|
||||
|
||||
}
|
185
teavm-dom/src/main/java/org/teavm/dom/html/HTMLMediaElement.java
Normal file
185
teavm-dom/src/main/java/org/teavm/dom/html/HTMLMediaElement.java
Normal file
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.html;
|
||||
|
||||
import java.util.Date;
|
||||
import org.teavm.dom.media.AudioTrackList;
|
||||
import org.teavm.dom.media.MediaController;
|
||||
import org.teavm.dom.media.MediaError;
|
||||
import org.teavm.dom.media.TextTrack;
|
||||
import org.teavm.dom.media.TextTrackList;
|
||||
import org.teavm.dom.media.TimeRanges;
|
||||
import org.teavm.dom.media.VideoTrackList;
|
||||
import org.teavm.jso.JSProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface HTMLMediaElement extends HTMLElement {
|
||||
|
||||
int HAVE_NOTHING = 0;
|
||||
int HAVE_METADATA = 1;
|
||||
int HAVE_CURRENT_DATA = 2;
|
||||
int HAVE_FUTURE_DATA = 3;
|
||||
int HAVE_ENOUGH_DATA = 4;
|
||||
|
||||
int NETWORK_EMPTY = 0;
|
||||
int NETWORK_IDLE = 1;
|
||||
int NETWORK_LOADING = 2;
|
||||
int NETWORK_NO_SOURCE = 3;
|
||||
|
||||
@JSProperty
|
||||
MediaError getError();
|
||||
|
||||
@JSProperty
|
||||
String getSrc();
|
||||
|
||||
@JSProperty
|
||||
void setSrc(String src);
|
||||
|
||||
@JSProperty
|
||||
String getCurrentSrc();
|
||||
|
||||
@JSProperty
|
||||
String getCrossOrigin();
|
||||
|
||||
@JSProperty
|
||||
void setCrossOrigin(String crossOrigin);
|
||||
|
||||
@JSProperty
|
||||
int getNetworkState();
|
||||
|
||||
@JSProperty
|
||||
String getPreload();
|
||||
|
||||
@JSProperty
|
||||
void setPreload(String preload);
|
||||
|
||||
@JSProperty
|
||||
TimeRanges getBuffered();
|
||||
|
||||
@JSProperty
|
||||
int getReadyState();
|
||||
|
||||
@JSProperty
|
||||
boolean isSeeking();
|
||||
|
||||
@JSProperty
|
||||
double getCurrentTime();
|
||||
|
||||
@JSProperty
|
||||
void setCurrentTime(double currentTime);
|
||||
|
||||
@JSProperty
|
||||
double getDuration();
|
||||
|
||||
@JSProperty
|
||||
Date getStartDate();
|
||||
|
||||
@JSProperty
|
||||
boolean isPaused();
|
||||
|
||||
@JSProperty
|
||||
double getDefaultPlaybackRate();
|
||||
|
||||
@JSProperty
|
||||
void setDefaultPlaybackRate(double defaultPlaybackRate);
|
||||
|
||||
@JSProperty
|
||||
double getPlaybackRate();
|
||||
|
||||
@JSProperty
|
||||
void setPlaybackRate(double playbackRate);
|
||||
|
||||
@JSProperty
|
||||
TimeRanges getPlayed();
|
||||
|
||||
@JSProperty
|
||||
TimeRanges getSeekable();
|
||||
|
||||
@JSProperty
|
||||
boolean isEnded();
|
||||
|
||||
@JSProperty
|
||||
boolean isAutoplay();
|
||||
|
||||
@JSProperty
|
||||
void setAutoplay(boolean autoplay);
|
||||
|
||||
@JSProperty
|
||||
boolean isLoop();
|
||||
|
||||
@JSProperty
|
||||
void setLoop(boolean loop);
|
||||
|
||||
@JSProperty
|
||||
String getMediaGroup();
|
||||
|
||||
@JSProperty
|
||||
void setMediaGroup(String mediaGroup);
|
||||
|
||||
@JSProperty
|
||||
MediaController getController();
|
||||
|
||||
@JSProperty
|
||||
void setController(MediaController controller);
|
||||
|
||||
@JSProperty
|
||||
boolean isControls();
|
||||
|
||||
@JSProperty
|
||||
void setControls(boolean controls);
|
||||
|
||||
@JSProperty
|
||||
float getVolume();
|
||||
|
||||
@JSProperty
|
||||
void setVolume(float volume);
|
||||
|
||||
@JSProperty
|
||||
boolean isMuted();
|
||||
|
||||
@JSProperty
|
||||
void setMuted(boolean muted);
|
||||
|
||||
@JSProperty
|
||||
boolean isDefaultMuted();
|
||||
|
||||
@JSProperty
|
||||
void setDefaultMuted(boolean defaultMuted);
|
||||
|
||||
AudioTrackList getAudioTracks();
|
||||
|
||||
VideoTrackList getVideoTracks();
|
||||
|
||||
TextTrackList getTextTracks();
|
||||
|
||||
TextTrack addTextTrack(String kind);
|
||||
|
||||
TextTrack addTextTrack(String kind, String label);
|
||||
|
||||
TextTrack addTextTrack(String kind, String label, String language);
|
||||
|
||||
void play();
|
||||
|
||||
void pause();
|
||||
|
||||
void load();
|
||||
|
||||
String canPlayType(String type);
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.html;
|
||||
|
||||
import org.teavm.jso.JSProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface HTMLSourceElement extends HTMLElement {
|
||||
|
||||
@JSProperty
|
||||
String getType();
|
||||
|
||||
@JSProperty
|
||||
void setType(String type);
|
||||
|
||||
@JSProperty
|
||||
String getSrc();
|
||||
|
||||
@JSProperty
|
||||
void setSrc(String src);
|
||||
|
||||
@JSProperty
|
||||
String getMedia();
|
||||
|
||||
@JSProperty
|
||||
void setMedia(String media);
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.html;
|
||||
|
||||
import org.teavm.jso.JSProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface HTMLVideoElement extends HTMLMediaElement {
|
||||
|
||||
@JSProperty
|
||||
int getWidth();
|
||||
|
||||
@JSProperty
|
||||
int getHeight();
|
||||
|
||||
@JSProperty
|
||||
void setWidth(int width);
|
||||
|
||||
@JSProperty
|
||||
void setHeight(int height);
|
||||
|
||||
@JSProperty
|
||||
int getVideoWidth();
|
||||
|
||||
@JSProperty
|
||||
int getVideoHeight();
|
||||
|
||||
@JSProperty
|
||||
String getPoster();
|
||||
|
||||
@JSProperty
|
||||
void setPoster(String poster);
|
||||
}
|
44
teavm-dom/src/main/java/org/teavm/dom/media/AudioTrack.java
Normal file
44
teavm-dom/src/main/java/org/teavm/dom/media/AudioTrack.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.media;
|
||||
|
||||
import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.JSProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface AudioTrack extends JSObject {
|
||||
|
||||
@JSProperty
|
||||
String getId();
|
||||
|
||||
@JSProperty
|
||||
String getLabel();
|
||||
|
||||
@JSProperty
|
||||
String getKind();
|
||||
|
||||
@JSProperty
|
||||
String getLanguage();
|
||||
|
||||
@JSProperty
|
||||
boolean isEnabled();
|
||||
|
||||
@JSProperty
|
||||
void setEnabled(boolean enabled);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.media;
|
||||
|
||||
import org.teavm.dom.events.EventTarget;
|
||||
import org.teavm.jso.JSArrayReader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface AudioTrackList extends EventTarget, JSArrayReader<AudioTrack> {
|
||||
|
||||
AudioTrack getTrackById(String id);
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.media;
|
||||
|
||||
import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.JSProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface MediaController extends JSObject {
|
||||
|
||||
@JSProperty
|
||||
TimeRanges getBuffered();
|
||||
|
||||
@JSProperty
|
||||
double getCurrentTime();
|
||||
|
||||
@JSProperty
|
||||
void setCurrentTime(double currentTime);
|
||||
|
||||
@JSProperty
|
||||
double getDefaultPlaybackRate();
|
||||
|
||||
@JSProperty
|
||||
void setDefaultPlaybackRate(double defaultPlaybackRate);
|
||||
|
||||
@JSProperty
|
||||
double getDuration();
|
||||
|
||||
@JSProperty
|
||||
boolean isMuted();
|
||||
|
||||
@JSProperty
|
||||
void setMuted(boolean muted);
|
||||
|
||||
@JSProperty
|
||||
boolean isPaused();
|
||||
|
||||
@JSProperty
|
||||
double getPlaybackRate();
|
||||
|
||||
@JSProperty
|
||||
void setPlaybackRate(double playbackRate);
|
||||
|
||||
@JSProperty
|
||||
String getPlaybackState();
|
||||
|
||||
@JSProperty
|
||||
TimeRanges getPlayed();
|
||||
|
||||
@JSProperty
|
||||
int getReadyState();
|
||||
|
||||
@JSProperty
|
||||
TimeRanges getSeekable();
|
||||
|
||||
@JSProperty
|
||||
float getVolume();
|
||||
|
||||
@JSProperty
|
||||
void setVolume(float volume);
|
||||
|
||||
void play();
|
||||
|
||||
void pause();
|
||||
}
|
34
teavm-dom/src/main/java/org/teavm/dom/media/MediaError.java
Normal file
34
teavm-dom/src/main/java/org/teavm/dom/media/MediaError.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.media;
|
||||
|
||||
import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.JSProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface MediaError extends JSObject {
|
||||
|
||||
int MEDIA_ERR_ABORTED = 1;
|
||||
int MEDIA_ERR_NETWORK = 2;
|
||||
int MEDIA_ERR_DECODE = 3;
|
||||
int MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
|
||||
|
||||
@JSProperty
|
||||
int getCode();
|
||||
}
|
58
teavm-dom/src/main/java/org/teavm/dom/media/TextTrack.java
Normal file
58
teavm-dom/src/main/java/org/teavm/dom/media/TextTrack.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.media;
|
||||
|
||||
import org.teavm.dom.events.EventTarget;
|
||||
import org.teavm.jso.JSProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface TextTrack extends EventTarget {
|
||||
|
||||
String DISABLED = "disabled";
|
||||
String HIDDEN = "hidden";
|
||||
String SHOWING = "showing";
|
||||
|
||||
@JSProperty
|
||||
String getId();
|
||||
|
||||
@JSProperty
|
||||
String getLabel();
|
||||
|
||||
@JSProperty
|
||||
String getKind();
|
||||
|
||||
@JSProperty
|
||||
String getLanguage();
|
||||
|
||||
@JSProperty
|
||||
String getMode();
|
||||
|
||||
@JSProperty
|
||||
void setMode(String mode);
|
||||
|
||||
@JSProperty
|
||||
TextTrackCueList getCues();
|
||||
|
||||
@JSProperty
|
||||
TextTrackCueList getActiveCues();
|
||||
|
||||
void addCue(TextTrackCue cue);
|
||||
|
||||
void removeCue(TextTrackCue cue);
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.media;
|
||||
|
||||
import org.teavm.dom.core.DocumentFragment;
|
||||
import org.teavm.dom.events.EventTarget;
|
||||
import org.teavm.jso.JSProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface TextTrackCue extends EventTarget {
|
||||
|
||||
@JSProperty
|
||||
TextTrack getTrack();
|
||||
|
||||
@JSProperty
|
||||
String getId();
|
||||
|
||||
@JSProperty
|
||||
void setId(String id);
|
||||
|
||||
@JSProperty
|
||||
double getStartTime();
|
||||
|
||||
@JSProperty
|
||||
void setStartTime(double startTime);
|
||||
|
||||
@JSProperty
|
||||
double getEndTime();
|
||||
|
||||
@JSProperty
|
||||
void setEndTime(double endTime);
|
||||
|
||||
@JSProperty
|
||||
boolean isPauseOnExit();
|
||||
|
||||
@JSProperty
|
||||
void setPauseOnExit(boolean pauseOnExit);
|
||||
|
||||
@JSProperty
|
||||
String getVertical();
|
||||
|
||||
@JSProperty
|
||||
void setVertical(String vertical);
|
||||
|
||||
@JSProperty
|
||||
boolean isSnapToLines();
|
||||
|
||||
@JSProperty
|
||||
void setSnapToLines(boolean snapToLines);
|
||||
|
||||
@JSProperty
|
||||
int getLine();
|
||||
|
||||
@JSProperty
|
||||
void setLine(int line);
|
||||
|
||||
@JSProperty
|
||||
int getPosition();
|
||||
|
||||
@JSProperty
|
||||
void setPosition(int position);
|
||||
|
||||
@JSProperty
|
||||
int getSize();
|
||||
|
||||
@JSProperty
|
||||
void setSize(int size);
|
||||
|
||||
@JSProperty
|
||||
String getAlign();
|
||||
|
||||
@JSProperty
|
||||
void setAlign(String align);
|
||||
|
||||
@JSProperty
|
||||
String getText();
|
||||
|
||||
@JSProperty
|
||||
void setText(String text);
|
||||
|
||||
DocumentFragment getCueAsHTML();
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.media;
|
||||
|
||||
import org.teavm.jso.JSArrayReader;
|
||||
import org.teavm.jso.JSObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface TextTrackCueList extends JSObject, JSArrayReader<TextTrackCue> {
|
||||
|
||||
TextTrackCue getCueById(String id);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.media;
|
||||
|
||||
import org.teavm.dom.events.EventTarget;
|
||||
import org.teavm.jso.JSArrayReader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface TextTrackList extends EventTarget, JSArrayReader<TextTrack> {
|
||||
|
||||
TextTrack getTrackById(String id);
|
||||
}
|
33
teavm-dom/src/main/java/org/teavm/dom/media/TimeRanges.java
Normal file
33
teavm-dom/src/main/java/org/teavm/dom/media/TimeRanges.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.media;
|
||||
|
||||
import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.JSProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface TimeRanges extends JSObject {
|
||||
|
||||
@JSProperty
|
||||
int getLength();
|
||||
|
||||
float start(int index);
|
||||
|
||||
float end(int index);
|
||||
}
|
44
teavm-dom/src/main/java/org/teavm/dom/media/VideoTrack.java
Normal file
44
teavm-dom/src/main/java/org/teavm/dom/media/VideoTrack.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.media;
|
||||
|
||||
import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.JSProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface VideoTrack extends JSObject {
|
||||
|
||||
@JSProperty
|
||||
String getId();
|
||||
|
||||
@JSProperty
|
||||
String getLabel();
|
||||
|
||||
@JSProperty
|
||||
String getKind();
|
||||
|
||||
@JSProperty
|
||||
String getLanguage();
|
||||
|
||||
@JSProperty
|
||||
boolean isSelected();
|
||||
|
||||
@JSProperty
|
||||
void setSelected(boolean selected);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.dom.media;
|
||||
|
||||
import org.teavm.dom.events.EventTarget;
|
||||
import org.teavm.jso.JSArrayReader;
|
||||
import org.teavm.jso.JSProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Junji Takakura
|
||||
*/
|
||||
public interface VideoTrackList extends EventTarget, JSArrayReader<VideoTrack> {
|
||||
|
||||
@JSProperty
|
||||
int getSelectedIndex();
|
||||
|
||||
VideoTrack getTrackById(String id);
|
||||
}
|
|
@ -33,5 +33,6 @@
|
|||
<module>teavm-samples-hello</module>
|
||||
<module>teavm-samples-benchmark</module>
|
||||
<module>teavm-samples-storage</module>
|
||||
<module>teavm-samples-video</module>
|
||||
</modules>
|
||||
</project>
|
110
teavm-samples/teavm-samples-video/pom.xml
Normal file
110
teavm-samples/teavm-samples-video/pom.xml
Normal file
|
@ -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>
|
|
@ -0,0 +1,221 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.samples.video;
|
||||
|
||||
import org.teavm.dom.browser.Window;
|
||||
import org.teavm.dom.events.Event;
|
||||
import org.teavm.dom.events.EventListener;
|
||||
import org.teavm.dom.html.HTMLBodyElement;
|
||||
import org.teavm.dom.html.HTMLButtonElement;
|
||||
import org.teavm.dom.html.HTMLDocument;
|
||||
import org.teavm.dom.html.HTMLElement;
|
||||
import org.teavm.dom.html.HTMLSourceElement;
|
||||
import org.teavm.dom.html.HTMLVideoElement;
|
||||
import org.teavm.jso.JS;
|
||||
|
||||
public final class Player {
|
||||
|
||||
private static Window window = (Window)JS.getGlobal();
|
||||
private static HTMLDocument document = window.getDocument();
|
||||
|
||||
private Player() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
HTMLSourceElement sourceMp4 = (HTMLSourceElement)document.createElement("source");
|
||||
sourceMp4.setAttribute("id", "mp4");
|
||||
sourceMp4.setSrc("http://media.w3.org/2010/05/sintel/trailer.mp4");
|
||||
sourceMp4.setAttribute("type", "video/mp4");
|
||||
|
||||
HTMLSourceElement sourceWebm = (HTMLSourceElement)document.createElement("source");
|
||||
sourceWebm.setAttribute("id", "webm");
|
||||
sourceWebm.setSrc("http://media.w3.org/2010/05/sintel/trailer.webm");
|
||||
sourceWebm.setAttribute("type", "video/webm");
|
||||
|
||||
HTMLSourceElement sourceOgv = (HTMLSourceElement)document.createElement("source");
|
||||
sourceOgv.setAttribute("id", "ogv");
|
||||
sourceOgv.setSrc("http://media.w3.org/2010/05/sintel/trailer.ogv");
|
||||
sourceOgv.setAttribute("type", "video/ogg");
|
||||
|
||||
HTMLElement p = document.createElement("p");
|
||||
p.appendChild(document.createTextNode("Your user agent does not support the HTML5 Video element."));
|
||||
|
||||
final HTMLVideoElement video = (HTMLVideoElement)document.createElement("video");
|
||||
video.setAttribute("id", "video");
|
||||
video.setControls(true);
|
||||
video.setPreload("none");
|
||||
video.setMediaGroup("myVideoGroup");
|
||||
video.setPoster("http://media.w3.org/2010/05/sintel/poster.png");
|
||||
video.appendChild(sourceMp4);
|
||||
video.appendChild(sourceWebm);
|
||||
video.appendChild(sourceOgv);
|
||||
video.appendChild(p);
|
||||
|
||||
HTMLElement divVideo = document.createElement("div");
|
||||
divVideo.appendChild(video);
|
||||
|
||||
HTMLButtonElement loadButton = (HTMLButtonElement)document.createElement("button");
|
||||
loadButton.appendChild(document.createTextNode("load()"));
|
||||
loadButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.load();
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement playButton = (HTMLButtonElement)document.createElement("button");
|
||||
playButton.appendChild(document.createTextNode("play()"));
|
||||
playButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.play();
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement pauseButton = (HTMLButtonElement)document.createElement("button");
|
||||
pauseButton.appendChild(document.createTextNode("pause()"));
|
||||
pauseButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.pause();
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement currentTimePlusButton = (HTMLButtonElement)document.createElement("button");
|
||||
currentTimePlusButton.appendChild(document.createTextNode("currentTime+=10"));
|
||||
currentTimePlusButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.setCurrentTime(video.getCurrentTime() + 10);
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement currentTimeMinusButton = (HTMLButtonElement)document.createElement("button");
|
||||
currentTimeMinusButton.appendChild(document.createTextNode("currentTime-=10"));
|
||||
currentTimeMinusButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.setCurrentTime(video.getCurrentTime() - 10);
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement currentTime50Button = (HTMLButtonElement)document.createElement("button");
|
||||
currentTime50Button.appendChild(document.createTextNode("currentTime=50"));
|
||||
currentTime50Button.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.setCurrentTime(50);
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement playbackRateIncrementButton = (HTMLButtonElement)document.createElement("button");
|
||||
playbackRateIncrementButton.appendChild(document.createTextNode("playbackRate++"));
|
||||
playbackRateIncrementButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.setPlaybackRate(video.getPlaybackRate() + 1);
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement playbackRateDecrementButton = (HTMLButtonElement)document.createElement("button");
|
||||
playbackRateDecrementButton.appendChild(document.createTextNode("playbackRate--"));
|
||||
playbackRateDecrementButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.setPlaybackRate(video.getPlaybackRate() - 1);
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement playbackRatePlusButton = (HTMLButtonElement)document.createElement("button");
|
||||
playbackRatePlusButton.appendChild(document.createTextNode("playbackRate+=0.1"));
|
||||
playbackRatePlusButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.setPlaybackRate(video.getPlaybackRate() + 0.1);
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement playbackRateMinusButton = (HTMLButtonElement)document.createElement("button");
|
||||
playbackRateMinusButton.appendChild(document.createTextNode("playbackRate-=0.1"));
|
||||
playbackRateMinusButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.setPlaybackRate(video.getPlaybackRate() - 0.1);
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement volumePlusButton = (HTMLButtonElement)document.createElement("button");
|
||||
volumePlusButton.appendChild(document.createTextNode("volume+=0.1"));
|
||||
volumePlusButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.setVolume(video.getVolume() + 0.1f);
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement volumeMinusButton = (HTMLButtonElement)document.createElement("button");
|
||||
volumeMinusButton.appendChild(document.createTextNode("volume-=0.1"));
|
||||
volumeMinusButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.setVolume(video.getVolume() - 0.1f);
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement muteButton = (HTMLButtonElement)document.createElement("button");
|
||||
muteButton.appendChild(document.createTextNode("muted=true"));
|
||||
muteButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.setMuted(true);
|
||||
}
|
||||
});
|
||||
|
||||
HTMLButtonElement unmuteButton = (HTMLButtonElement)document.createElement("button");
|
||||
unmuteButton.appendChild(document.createTextNode("muted=false"));
|
||||
unmuteButton.addEventListener("click", new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
video.setMuted(false);
|
||||
}
|
||||
});
|
||||
|
||||
HTMLElement divButtons = document.createElement("div");
|
||||
divButtons.setAttribute("id", "buttons");
|
||||
divButtons.appendChild(loadButton);
|
||||
divButtons.appendChild(playButton);
|
||||
divButtons.appendChild(pauseButton);
|
||||
divButtons.appendChild(document.createElement("br"));
|
||||
divButtons.appendChild(currentTimePlusButton);
|
||||
divButtons.appendChild(currentTimeMinusButton);
|
||||
divButtons.appendChild(currentTime50Button);
|
||||
divButtons.appendChild(document.createElement("br"));
|
||||
divButtons.appendChild(playbackRateIncrementButton);
|
||||
divButtons.appendChild(playbackRateDecrementButton);
|
||||
divButtons.appendChild(playbackRatePlusButton);
|
||||
divButtons.appendChild(playbackRateMinusButton);
|
||||
divButtons.appendChild(document.createElement("br"));
|
||||
divButtons.appendChild(volumePlusButton);
|
||||
divButtons.appendChild(volumeMinusButton);
|
||||
divButtons.appendChild(muteButton);
|
||||
divButtons.appendChild(unmuteButton);
|
||||
|
||||
HTMLBodyElement body = document.getBody();
|
||||
body.appendChild(divVideo);
|
||||
body.appendChild(divButtons);
|
||||
}
|
||||
|
||||
}
|
|
@ -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>
|
28
teavm-samples/teavm-samples-video/src/main/webapp/index.html
Normal file
28
teavm-samples/teavm-samples-video/src/main/webapp/index.html
Normal file
|
@ -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>
|
12
teavm-samples/teavm-samples-video/src/main/webapp/style.css
Normal file
12
teavm-samples/teavm-samples-video/src/main/webapp/style.css
Normal file
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user