mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-03 05:44:10 -08:00
Rewrite with lambdas some more code
This commit is contained in:
parent
6f3d80ffe1
commit
c20209e651
|
@ -264,9 +264,9 @@ class TByteBufferImpl extends TByteBuffer {
|
|||
int d = array[start + position + 3] & 0xFF;
|
||||
position += 4;
|
||||
if (order == TByteOrder.BIG_ENDIAN) {
|
||||
return (int)((a << 24) | (b << 16) | (c << 8) | d);
|
||||
return (a << 24) | (b << 16) | (c << 8) | d;
|
||||
} else {
|
||||
return (int)((d << 24) | (c << 16) | (b << 8) | a);
|
||||
return (d << 24) | (c << 16) | (b << 8) | a;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,9 +302,9 @@ class TByteBufferImpl extends TByteBuffer {
|
|||
int c = array[start + index + 2] & 0xFF;
|
||||
int d = array[start + index + 3] & 0xFF;
|
||||
if (order == TByteOrder.BIG_ENDIAN) {
|
||||
return (int)((a << 24) | (b << 16) | (c << 8) | d);
|
||||
return (a << 24) | (b << 16) | (c << 8) | d;
|
||||
} else {
|
||||
return (int)((d << 24) | (c << 16) | (b << 8) | a);
|
||||
return (d << 24) | (c << 16) | (b << 8) | a;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,9 +355,9 @@ class TByteBufferImpl extends TByteBuffer {
|
|||
long h = array[start + position + 7] & 0xFF;
|
||||
position += 8;
|
||||
if (order == TByteOrder.BIG_ENDIAN) {
|
||||
return (long)((a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) | (f << 16) | (g << 8) | h);
|
||||
return (a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) | (f << 16) | (g << 8) | h;
|
||||
} else {
|
||||
return (long)((h << 56) | (g << 48) | (f << 40) | (e << 32) | (d << 24) | (c << 16) | (b << 8) | a);
|
||||
return (h << 56) | (g << 48) | (f << 40) | (e << 32) | (d << 24) | (c << 16) | (b << 8) | a;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,9 +406,9 @@ class TByteBufferImpl extends TByteBuffer {
|
|||
long h = array[start + index + 7] & 0xFF;
|
||||
position += 8;
|
||||
if (order == TByteOrder.BIG_ENDIAN) {
|
||||
return (long)((a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) | (f << 16) | (g << 8) | h);
|
||||
return (a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) | (f << 16) | (g << 8) | h;
|
||||
} else {
|
||||
return (long)((h << 56) | (g << 48) | (f << 40) | (e << 32) | (d << 24) | (c << 16) | (b << 8) | a);
|
||||
return (h << 56) | (g << 48) | (f << 40) | (e << 32) | (d << 24) | (c << 16) | (b << 8) | a;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -515,9 +515,7 @@ public final class JS {
|
|||
JSObject c, JSObject d, JSObject e, JSObject f, JSObject g, JSObject h);
|
||||
|
||||
public static <T extends JSObject> Iterable<T> iterate(final JSArrayReader<T> array) {
|
||||
return new Iterable<T>() {
|
||||
@Override public Iterator<T> iterator() {
|
||||
return new Iterator<T>() {
|
||||
return () -> new Iterator<T>() {
|
||||
int index;
|
||||
@Override public boolean hasNext() {
|
||||
return index < array.getLength();
|
||||
|
@ -530,13 +528,9 @@ public final class JS {
|
|||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Iterable<String> iterate(final JSStringArrayReader array) {
|
||||
return new Iterable<String>() {
|
||||
@Override public Iterator<String> iterator() {
|
||||
return new Iterator<String>() {
|
||||
return () -> new Iterator<String>() {
|
||||
int index;
|
||||
@Override public boolean hasNext() {
|
||||
return index < array.getLength();
|
||||
|
@ -549,8 +543,6 @@ public final class JS {
|
|||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@InjectedBy(JSNativeGenerator.class)
|
||||
public static native JSObject get(JSObject instance, JSObject index);
|
||||
|
|
|
@ -166,11 +166,7 @@ public class JSNativeGenerator implements Injector, DependencyPlugin, Generator
|
|||
case "instantiate":
|
||||
case "function":
|
||||
for (int i = 0; i < method.getReference().parameterCount(); ++i) {
|
||||
method.getVariable(i).addConsumer(new DependencyConsumer() {
|
||||
@Override public void consume(DependencyType type) {
|
||||
achieveFunctorMethods(agent, type.getName(), method);
|
||||
}
|
||||
});
|
||||
method.getVariable(i).addConsumer(type -> achieveFunctorMethods(agent, type.getName(), method));
|
||||
}
|
||||
break;
|
||||
case "unwrapString":
|
||||
|
|
|
@ -115,7 +115,7 @@ class JavascriptNativeProcessor {
|
|||
return null;
|
||||
}
|
||||
Map<MethodDescriptor, MethodReference> methods = new HashMap<>();
|
||||
getFunctorMethods(className, new HashSet<String>(), methods);
|
||||
getFunctorMethods(className, new HashSet<>(), methods);
|
||||
if (methods.size() == 1) {
|
||||
return methods.values().iterator().next();
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ class JavascriptNativeProcessor {
|
|||
|
||||
public void makeSync(ClassHolder cls) {
|
||||
Set<MethodDescriptor> methods = new HashSet<>();
|
||||
findInheritedMethods(cls, methods, new HashSet<String>());
|
||||
findInheritedMethods(cls, methods, new HashSet<>());
|
||||
for (MethodHolder method : cls.getMethods()) {
|
||||
if (methods.contains(method.getDescriptor()) && method.getAnnotations().get(Sync.class.getName()) == null) {
|
||||
AnnotationHolder annot = new AnnotationHolder(Sync.class.getName());
|
||||
|
@ -544,9 +544,8 @@ class JavascriptNativeProcessor {
|
|||
// create program that invokes proxy method
|
||||
program = new Program();
|
||||
BasicBlock block = program.createBasicBlock();
|
||||
List<Variable> params = new ArrayList<>();
|
||||
for (int i = 0; i < paramCount; ++i) {
|
||||
params.add(program.createVariable());
|
||||
program.createVariable();
|
||||
}
|
||||
if (isStatic) {
|
||||
program.createVariable();
|
||||
|
|
|
@ -59,17 +59,12 @@ class NativeJavascriptClassRepository {
|
|||
if (cls == null || !(cls.hasModifier(ElementModifier.INTERFACE) || cls.hasModifier(ElementModifier.ABSTRACT))) {
|
||||
return false;
|
||||
}
|
||||
for (String iface : cls.getInterfaces()) {
|
||||
if (isJavaScriptClass(iface)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) {
|
||||
if (isJavaScriptClass(cls.getParent())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return cls.getInterfaces().stream().anyMatch(iface -> isJavaScriptClass(iface));
|
||||
}
|
||||
|
||||
private boolean examineIfJavaScriptImplementation(String className) {
|
||||
|
@ -85,11 +80,6 @@ class NativeJavascriptClassRepository {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
for (String iface : cls.getInterfaces()) {
|
||||
if (isJavaScriptClass(iface)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return cls.getInterfaces().stream().anyMatch(iface -> isJavaScriptClass(iface));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,7 @@ package org.teavm.platform.plugin;
|
|||
import java.lang.annotation.Annotation;
|
||||
import org.teavm.dependency.AbstractDependencyListener;
|
||||
import org.teavm.dependency.DependencyAgent;
|
||||
import org.teavm.dependency.DependencyConsumer;
|
||||
import org.teavm.dependency.DependencyNode;
|
||||
import org.teavm.dependency.DependencyType;
|
||||
import org.teavm.dependency.MethodDependency;
|
||||
import org.teavm.model.CallLocation;
|
||||
import org.teavm.model.MethodReference;
|
||||
|
@ -46,15 +44,13 @@ public class AnnotationDependencySupport extends AbstractDependencyListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void methodReached(final DependencyAgent agent, final MethodDependency method,
|
||||
final CallLocation location) {
|
||||
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||
if (method.getReference().getClassName().equals(Platform.class.getName()) &&
|
||||
method.getReference().getName().equals("getAnnotations")) {
|
||||
method.getResult().propagate(agent.getType("[" + Annotation.class.getName()));
|
||||
agent.linkMethod(new MethodReference(PlatformAnnotationProvider.class, "getAnnotations",
|
||||
Annotation[].class), location);
|
||||
allClasses.addConsumer(new DependencyConsumer() {
|
||||
@Override public void consume(DependencyType type) {
|
||||
allClasses.addConsumer(type -> {
|
||||
if (type.getName().endsWith("$$__annotations__$$")) {
|
||||
return;
|
||||
}
|
||||
|
@ -66,7 +62,6 @@ public class AnnotationDependencySupport extends AbstractDependencyListener {
|
|||
"getAnnotations", ValueType.parse(Annotation[].class)), location);
|
||||
readMethod.getResult().getArrayItem().connect(method.getResult().getArrayItem());
|
||||
readMethod.use();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,16 @@ import java.io.IOException;
|
|||
import org.teavm.codegen.SourceWriter;
|
||||
import org.teavm.dependency.DependencyAgent;
|
||||
import org.teavm.dependency.DependencyPlugin;
|
||||
import org.teavm.dependency.DependencyType;
|
||||
import org.teavm.dependency.DependencyTypeFilter;
|
||||
import org.teavm.dependency.MethodDependency;
|
||||
import org.teavm.javascript.spi.Generator;
|
||||
import org.teavm.javascript.spi.GeneratorContext;
|
||||
import org.teavm.model.*;
|
||||
import org.teavm.model.CallLocation;
|
||||
import org.teavm.model.ClassReader;
|
||||
import org.teavm.model.ClassReaderSource;
|
||||
import org.teavm.model.ElementModifier;
|
||||
import org.teavm.model.MethodReader;
|
||||
import org.teavm.model.MethodReference;
|
||||
import org.teavm.model.ValueType;
|
||||
import org.teavm.platform.async.AsyncCallback;
|
||||
|
||||
/**
|
||||
|
@ -95,7 +99,7 @@ public class AsyncMethodGenerator implements Generator, DependencyPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void methodAchieved(final DependencyAgent checker, final MethodDependency method, CallLocation location) {
|
||||
public void methodAchieved(DependencyAgent checker, MethodDependency method, CallLocation location) {
|
||||
MethodReference asyncRef = getAsyncReference(method.getReference());
|
||||
MethodDependency asyncMethod = checker.linkMethod(asyncRef, location);
|
||||
int paramCount = method.getReference().parameterCount();
|
||||
|
@ -107,12 +111,8 @@ public class AsyncMethodGenerator implements Generator, DependencyPlugin {
|
|||
MethodDependency completeMethod = checker.linkMethod(
|
||||
new MethodReference(AsyncCallbackWrapper.class, "complete", Object.class, void.class), null);
|
||||
if (method.getResult() != null) {
|
||||
completeMethod.getVariable(1).connect(method.getResult(), new DependencyTypeFilter() {
|
||||
@Override
|
||||
public boolean match(DependencyType type) {
|
||||
return isSubtype(checker.getClassSource(), type.getName(), method.getReference().getReturnType());
|
||||
}
|
||||
});
|
||||
completeMethod.getVariable(1).connect(method.getResult(), type -> isSubtype(checker.getClassSource(),
|
||||
type.getName(), method.getReference().getReturnType()));
|
||||
}
|
||||
completeMethod.use();
|
||||
|
||||
|
@ -150,11 +150,6 @@ public class AsyncMethodGenerator implements Generator, DependencyPlugin {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
for (String iface : cls.getInterfaces()) {
|
||||
if (isSubclass(classSource, iface, baseClass)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return cls.getInterfaces().stream().anyMatch(iface -> isSubclass(classSource, iface, baseClass));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,11 +37,10 @@ public class ClassLookupDependencySupport extends AbstractDependencyListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void methodReached(final DependencyAgent agent, MethodDependency method, final CallLocation location) {
|
||||
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||
MethodReference ref = method.getReference();
|
||||
if (ref.getClassName().equals(Platform.class.getName()) && ref.getName().equals("lookupClass")) {
|
||||
allClasses.addConsumer(new DependencyConsumer() {
|
||||
@Override public void consume(DependencyType type) {
|
||||
allClasses.addConsumer(type -> {
|
||||
ClassReader cls = agent.getClassSource().get(type.getName());
|
||||
if (cls == null) {
|
||||
return;
|
||||
|
@ -50,7 +49,6 @@ public class ClassLookupDependencySupport extends AbstractDependencyListener {
|
|||
if (initMethod != null) {
|
||||
agent.linkMethod(initMethod.getReference(), location).use();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,7 @@ package org.teavm.platform.plugin;
|
|||
|
||||
import org.teavm.dependency.AbstractDependencyListener;
|
||||
import org.teavm.dependency.DependencyAgent;
|
||||
import org.teavm.dependency.DependencyConsumer;
|
||||
import org.teavm.dependency.DependencyNode;
|
||||
import org.teavm.dependency.DependencyType;
|
||||
import org.teavm.dependency.MethodDependency;
|
||||
import org.teavm.model.CallLocation;
|
||||
import org.teavm.model.ClassReader;
|
||||
|
@ -51,19 +49,17 @@ public class EnumDependencySupport extends AbstractDependencyListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void methodReached(final DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||
if (method.getReference().getClassName().equals(Platform.class.getName()) &&
|
||||
method.getReference().getName().equals("getEnumConstants")) {
|
||||
allEnums.connect(method.getResult().getArrayItem());
|
||||
final MethodReference ref = method.getReference();
|
||||
allEnums.addConsumer(new DependencyConsumer() {
|
||||
@Override public void consume(DependencyType type) {
|
||||
allEnums.addConsumer(type -> {
|
||||
ClassReader cls = agent.getClassSource().get(type.getName());
|
||||
MethodReader method = cls.getMethod(new MethodDescriptor("values",
|
||||
MethodReader valuesMethod = cls.getMethod(new MethodDescriptor("values",
|
||||
ValueType.arrayOf(ValueType.object(cls.getName()))));
|
||||
if (method != null) {
|
||||
agent.linkMethod(method.getReference(), new CallLocation(ref)).use();
|
||||
}
|
||||
if (valuesMethod != null) {
|
||||
agent.linkMethod(valuesMethod.getReference(), new CallLocation(ref)).use();
|
||||
}
|
||||
});
|
||||
method.getResult().propagate(agent.getType("[java.lang.Enum"));
|
||||
|
|
|
@ -47,16 +47,13 @@ public class NewInstanceDependencySupport extends AbstractDependencyListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void methodReached(final DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||
MethodReader reader = method.getMethod();
|
||||
if (reader.getOwnerName().equals(Platform.class.getName()) && reader.getName().equals("newInstanceImpl")) {
|
||||
allClassesNode.connect(method.getResult());
|
||||
final MethodReference methodRef = reader.getReference();
|
||||
method.getResult().addConsumer(new DependencyConsumer() {
|
||||
@Override public void consume(DependencyType type) {
|
||||
attachConstructor(agent, type.getName(), new CallLocation(methodRef));
|
||||
}
|
||||
});
|
||||
MethodReference methodRef = reader.getReference();
|
||||
method.getResult().addConsumer(type -> attachConstructor(agent, type.getName(),
|
||||
new CallLocation(methodRef)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public class PlatformGenerator implements Generator, Injector, DependencyPlugin
|
|||
case "classFromResource":
|
||||
case "objectFromResource":
|
||||
context.writeExpr(context.getArgument(0));
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
package org.teavm.samples.video;
|
||||
|
||||
import org.teavm.dom.browser.Window;
|
||||
import org.teavm.dom.events.EventListener;
|
||||
import org.teavm.dom.events.MouseEvent;
|
||||
import org.teavm.dom.html.HTMLBodyElement;
|
||||
import org.teavm.dom.html.HTMLButtonElement;
|
||||
import org.teavm.dom.html.HTMLDocument;
|
||||
|
@ -53,7 +51,7 @@ public final class Player {
|
|||
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");
|
||||
HTMLVideoElement video = (HTMLVideoElement)document.createElement("video");
|
||||
video.setAttribute("id", "video");
|
||||
video.setControls(true);
|
||||
video.setPreload("none");
|
||||
|
@ -69,129 +67,61 @@ public final class Player {
|
|||
|
||||
HTMLButtonElement loadButton = (HTMLButtonElement)document.createElement("button");
|
||||
loadButton.appendChild(document.createTextNode("load()"));
|
||||
loadButton.addEventListener("click", new EventListener<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.load();
|
||||
}
|
||||
});
|
||||
loadButton.addEventListener("click", evt -> video.load());
|
||||
|
||||
HTMLButtonElement playButton = (HTMLButtonElement)document.createElement("button");
|
||||
playButton.appendChild(document.createTextNode("play()"));
|
||||
playButton.addEventListener("click", new EventListener<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.play();
|
||||
}
|
||||
});
|
||||
playButton.addEventListener("click", evt -> video.play());
|
||||
|
||||
HTMLButtonElement pauseButton = (HTMLButtonElement)document.createElement("button");
|
||||
pauseButton.appendChild(document.createTextNode("pause()"));
|
||||
pauseButton.addEventListener("click", new EventListener<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.pause();
|
||||
}
|
||||
});
|
||||
pauseButton.addEventListener("click", evt -> video.pause());
|
||||
|
||||
HTMLButtonElement currentTimePlusButton = (HTMLButtonElement)document.createElement("button");
|
||||
currentTimePlusButton.appendChild(document.createTextNode("currentTime+=10"));
|
||||
currentTimePlusButton.addEventListener("click", new EventListener<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.setCurrentTime(video.getCurrentTime() + 10);
|
||||
}
|
||||
});
|
||||
currentTimePlusButton.addEventListener("click", evt -> video.setCurrentTime(video.getCurrentTime() + 10));
|
||||
|
||||
HTMLButtonElement currentTimeMinusButton = (HTMLButtonElement)document.createElement("button");
|
||||
currentTimeMinusButton.appendChild(document.createTextNode("currentTime-=10"));
|
||||
currentTimeMinusButton.addEventListener("click", new EventListener<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.setCurrentTime(video.getCurrentTime() - 10);
|
||||
}
|
||||
});
|
||||
currentTimeMinusButton.addEventListener("click", evt -> video.setCurrentTime(video.getCurrentTime() - 10));
|
||||
|
||||
HTMLButtonElement currentTime50Button = (HTMLButtonElement)document.createElement("button");
|
||||
currentTime50Button.appendChild(document.createTextNode("currentTime=50"));
|
||||
currentTime50Button.addEventListener("click", new EventListener<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.setCurrentTime(50);
|
||||
}
|
||||
});
|
||||
currentTime50Button.addEventListener("click", evt -> video.setCurrentTime(50));
|
||||
|
||||
HTMLButtonElement playbackRateIncrementButton = (HTMLButtonElement)document.createElement("button");
|
||||
playbackRateIncrementButton.appendChild(document.createTextNode("playbackRate++"));
|
||||
playbackRateIncrementButton.addEventListener("click", new EventListener<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.setPlaybackRate(video.getPlaybackRate() + 1);
|
||||
}
|
||||
});
|
||||
playbackRateIncrementButton.addEventListener("click", evt -> video.setPlaybackRate(
|
||||
video.getPlaybackRate() + 1));
|
||||
|
||||
HTMLButtonElement playbackRateDecrementButton = (HTMLButtonElement)document.createElement("button");
|
||||
playbackRateDecrementButton.appendChild(document.createTextNode("playbackRate--"));
|
||||
playbackRateDecrementButton.addEventListener("click", new EventListener<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.setPlaybackRate(video.getPlaybackRate() - 1);
|
||||
}
|
||||
});
|
||||
playbackRateDecrementButton.addEventListener("click", evt -> video.setPlaybackRate(
|
||||
video.getPlaybackRate() - 1));
|
||||
|
||||
HTMLButtonElement playbackRatePlusButton = (HTMLButtonElement)document.createElement("button");
|
||||
playbackRatePlusButton.appendChild(document.createTextNode("playbackRate+=0.1"));
|
||||
playbackRatePlusButton.addEventListener("click", new EventListener<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.setPlaybackRate(video.getPlaybackRate() + 0.1);
|
||||
}
|
||||
});
|
||||
playbackRatePlusButton.addEventListener("click", 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<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.setPlaybackRate(video.getPlaybackRate() - 0.1);
|
||||
}
|
||||
});
|
||||
playbackRateMinusButton.addEventListener("click", 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<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.setVolume(video.getVolume() + 0.1f);
|
||||
}
|
||||
});
|
||||
volumePlusButton.addEventListener("click", 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<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.setVolume(video.getVolume() - 0.1f);
|
||||
}
|
||||
});
|
||||
volumeMinusButton.addEventListener("click", evt -> video.setVolume(video.getVolume() - 0.1f));
|
||||
|
||||
HTMLButtonElement muteButton = (HTMLButtonElement)document.createElement("button");
|
||||
muteButton.appendChild(document.createTextNode("muted=true"));
|
||||
muteButton.addEventListener("click", new EventListener<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.setMuted(true);
|
||||
}
|
||||
});
|
||||
muteButton.addEventListener("click", evt -> video.setMuted(true));
|
||||
|
||||
HTMLButtonElement unmuteButton = (HTMLButtonElement)document.createElement("button");
|
||||
unmuteButton.appendChild(document.createTextNode("muted=false"));
|
||||
unmuteButton.addEventListener("click", new EventListener<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
video.setMuted(false);
|
||||
}
|
||||
});
|
||||
unmuteButton.addEventListener("click", evt -> video.setMuted(false));
|
||||
|
||||
HTMLElement divButtons = document.createElement("div");
|
||||
divButtons.setAttribute("id", "buttons");
|
||||
|
|
Loading…
Reference in New Issue
Block a user