22w34c Re-implement music disc functionality & add asset overrides.
Music discs are NOT implemented by default, due to file size; you must manually add them yourself to hear them.
This commit is contained in:
parent
47a81e6589
commit
78e502bb7a
Binary file not shown.
36834
javascript/classes.js
36834
javascript/classes.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
3
javascript/index.html
vendored
3
javascript/index.html
vendored
|
@ -12,6 +12,9 @@ alert("You're not supposed to 'open' this file in your browser. Please upload th
|
|||
window.addEventListener("load", function(){
|
||||
window.eaglercraftOpts = {
|
||||
container: "game_frame", assetsURI: "assets.epk", serverWorkerURI: "worker_bootstrap.js", worldsFolder: "TEST",
|
||||
assetOverrides: {
|
||||
"records/wait.mp3": "wait.mp3"
|
||||
},
|
||||
servers: [
|
||||
{ serverName: "Local Test Server", serverAddress: "localhost:25565", hideAddress: false }
|
||||
],
|
||||
|
|
BIN
javascript/wait.mp3
Normal file
BIN
javascript/wait.mp3
Normal file
Binary file not shown.
|
@ -10,10 +10,29 @@ import java.util.HashMap;
|
|||
import com.jcraft.jzlib.CRC32;
|
||||
import com.jcraft.jzlib.GZIPInputStream;
|
||||
import com.jcraft.jzlib.InflaterInputStream;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class AssetRepository {
|
||||
|
||||
private static final HashMap<String,byte[]> filePool = new HashMap();
|
||||
public static final HashMap<String, String> fileNameOverrides = new HashMap();
|
||||
|
||||
public static final void loadOverrides(JSONObject json) {
|
||||
JSONObject overrides = json.optJSONObject("assetOverrides", null);
|
||||
if (overrides != null) {
|
||||
for (String fileName : overrides.keySet()) {
|
||||
if(fileName.startsWith("/")) fileName = fileName.substring(1);
|
||||
String val = overrides.optString(fileName, null);
|
||||
if (val != null) {
|
||||
AssetRepository.fileNameOverrides.put(fileName, val);
|
||||
if (!fileName.toLowerCase().endsWith(".mp3")) {
|
||||
loadFromURL(fileName, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final void install(byte[] pkg) throws IOException {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(pkg);
|
||||
|
@ -209,4 +228,8 @@ public class AssetRepository {
|
|||
return filePool.get(path);
|
||||
}
|
||||
|
||||
public static final void loadFromURL(String path, String url) {
|
||||
filePool.put(path, EaglerAdapter.downloadURL(url));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ public class ConfigConstants {
|
|||
|
||||
public static boolean profanity = false;
|
||||
|
||||
public static final String version = "22w34b";
|
||||
public static final String version = "22w34c";
|
||||
public static final String mainMenuString = "eaglercraft " + version;
|
||||
|
||||
public static final String forkMe = "https://github.com/lax1dude/eaglercraft";
|
||||
|
|
|
@ -18,7 +18,7 @@ public class GameSettings {
|
|||
private static final String[] LIMIT_FRAMERATES = new String[] { "performance.max", "performance.balanced", "performance.powersaver" };
|
||||
private static final String[] AMBIENT_OCCLUSIONS = new String[] { "options.ao.off", "options.ao.min", "options.ao.max" };
|
||||
private static final String[] ANTIALIASING = new String[] { "options.framebufferAntialias.none", "options.framebufferAntialias.auto", "options.framebufferAntialias.fxaa" , "options.framebufferAntialias.msaa4", "options.framebufferAntialias.msaa8" };
|
||||
public float musicVolume = 0.0F;
|
||||
public float musicVolume = 1.0F;
|
||||
public float soundVolume = 1.0F;
|
||||
public float mouseSensitivity = 0.5F;
|
||||
public boolean invertMouse = false;
|
||||
|
|
|
@ -1549,15 +1549,13 @@ public class RenderGlobal implements IWorldAccess {
|
|||
* Plays the specified record. Arg: recordName, x, y, z
|
||||
*/
|
||||
public void playRecord(String par1Str, int par2, int par3, int par4) {
|
||||
Minecraft.getMinecraft().displayEaglercraftText("records have been deleted to reduce file size");
|
||||
|
||||
ItemRecord var5 = ItemRecord.getRecord(par1Str);
|
||||
|
||||
if (par1Str != null && var5 != null) {
|
||||
this.mc.ingameGUI.setRecordPlayingMessage(var5.getRecordTitle());
|
||||
}
|
||||
|
||||
this.mc.sndManager.playStreaming(par1Str, (float) par2, (float) par3, (float) par4);
|
||||
this.mc.sndManager.playStreaming(par1Str, (float)par2 + 0.5F, (float)par3 + 0.5F, (float)par4 + 0.5F, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.lax1dude.eaglercraft.AssetRepository;
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.EaglercraftRandom;
|
||||
|
||||
|
@ -41,12 +42,14 @@ public class SoundManager {
|
|||
private GameSettings options;
|
||||
private ArrayList<EntitySoundEvent> soundevents;
|
||||
private ArrayList<QueuedSoundEvent> queuedsoundevents;
|
||||
private ArrayList<Integer> activerecords;
|
||||
private HashMap<String,Integer> sounddefinitions;
|
||||
private EaglercraftRandom soundrandom;
|
||||
|
||||
public SoundManager() {
|
||||
this.soundevents = new ArrayList();
|
||||
this.queuedsoundevents = new ArrayList();
|
||||
this.activerecords = new ArrayList();
|
||||
this.sounddefinitions = null;
|
||||
this.soundrandom = new EaglercraftRandom();
|
||||
}
|
||||
|
@ -78,6 +81,7 @@ public class SoundManager {
|
|||
* Called when one of the sound level options has changed.
|
||||
*/
|
||||
public void onSoundOptionsChanged() {
|
||||
EaglerAdapter.setMusicVolume(options.musicVolume);
|
||||
EaglerAdapter.setMasterVolume(options.soundVolume);
|
||||
}
|
||||
|
||||
|
@ -123,10 +127,29 @@ public class SoundManager {
|
|||
for(EntitySoundEvent e : soundevents) {
|
||||
EaglerAdapter.endSound(e.id);
|
||||
}
|
||||
for(Integer i : activerecords) {
|
||||
EaglerAdapter.endSound(i.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void playStreaming(String par1Str, float par2, float par3, float par4) {
|
||||
playStreaming(par1Str, par2, par3, par4, false);
|
||||
}
|
||||
|
||||
public void playStreaming(String par1Str, float par2, float par3, float par4, boolean music) {
|
||||
for (Integer record : activerecords) {
|
||||
EaglerAdapter.endSound(record.intValue());
|
||||
}
|
||||
activerecords.clear();
|
||||
if (par1Str != null) {
|
||||
String path = "/records/" + par1Str.replace('.', '/') + ".mp3";
|
||||
int snd = EaglerAdapter.beginPlayback(path, par2, par3, par4, 1.0F, 1.0F, music);
|
||||
if (snd != -1) {
|
||||
activerecords.add(new Integer(snd));
|
||||
} else {
|
||||
System.err.println("unregistered record: "+par1Str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -327,7 +350,7 @@ public class SoundManager {
|
|||
|
||||
public void playTheTitleMusic() {
|
||||
if(titleMusic == -1 || !EaglerAdapter.isPlaying(titleMusic)) {
|
||||
titleMusic = EaglerAdapter.beginPlaybackStatic("/sounds/gta.mp3", 1.0f, 1.0f);
|
||||
titleMusic = EaglerAdapter.beginPlaybackStatic("/sounds/gta.mp3", 1.0f, 1.0f, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ public class Client {
|
|||
|
||||
registerErrorHandler();
|
||||
ServerList.loadDefaultServers(conf);
|
||||
AssetRepository.loadOverrides(conf);
|
||||
LocalStorageManager.loadStorage();
|
||||
|
||||
run0();
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.teavm.jso.dom.events.KeyboardEvent;
|
|||
import org.teavm.jso.dom.events.MessageEvent;
|
||||
import org.teavm.jso.dom.events.MouseEvent;
|
||||
import org.teavm.jso.dom.events.WheelEvent;
|
||||
import org.teavm.jso.dom.html.HTMLAudioElement;
|
||||
import org.teavm.jso.dom.html.HTMLCanvasElement;
|
||||
import org.teavm.jso.dom.html.HTMLDocument;
|
||||
import org.teavm.jso.dom.html.HTMLElement;
|
||||
|
@ -64,6 +65,8 @@ import org.teavm.jso.webaudio.AudioBuffer;
|
|||
import org.teavm.jso.webaudio.AudioBufferSourceNode;
|
||||
import org.teavm.jso.webaudio.AudioContext;
|
||||
import org.teavm.jso.webaudio.AudioListener;
|
||||
import org.teavm.jso.webaudio.AudioNode;
|
||||
import org.teavm.jso.webaudio.ChannelMergerNode;
|
||||
import org.teavm.jso.webaudio.DecodeErrorCallback;
|
||||
import org.teavm.jso.webaudio.DecodeSuccessCallback;
|
||||
import org.teavm.jso.webaudio.GainNode;
|
||||
|
@ -161,10 +164,10 @@ public class EaglerAdapterImpl2 {
|
|||
return contents.replace("\r\n", "\n").split("[\r\n]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Async
|
||||
public static native String downloadAssetPack(String assetPackageURI);
|
||||
|
||||
|
||||
private static void downloadAssetPack(String assetPackageURI, final AsyncCallback<String> cb) {
|
||||
final XMLHttpRequest request = XMLHttpRequest.create();
|
||||
request.setResponseType("arraybuffer");
|
||||
|
@ -185,6 +188,29 @@ public class EaglerAdapterImpl2 {
|
|||
request.send();
|
||||
}
|
||||
|
||||
@Async
|
||||
public static native byte[] downloadURL(String url);
|
||||
|
||||
private static void downloadURL(String url, final AsyncCallback<byte[]> cb) {
|
||||
final XMLHttpRequest request = XMLHttpRequest.create();
|
||||
request.setResponseType("arraybuffer");
|
||||
request.open("GET", url, true);
|
||||
request.setOnReadyStateChange(new ReadyStateChangeHandler() {
|
||||
@Override
|
||||
public void stateChanged() {
|
||||
if(request.getReadyState() == XMLHttpRequest.DONE) {
|
||||
Uint8Array bl = Uint8Array.create((ArrayBuffer)request.getResponse());
|
||||
byte[] res = new byte[bl.getByteLength()];
|
||||
for(int i = 0; i < res.length; ++i) {
|
||||
res[i] = (byte) bl.get(i);
|
||||
}
|
||||
cb.complete(res);
|
||||
}
|
||||
}
|
||||
});
|
||||
request.send();
|
||||
}
|
||||
|
||||
@JSBody(params = { "v", "s" }, script = "window[v] = s;")
|
||||
public static native void setDebugVar(String v, String s);
|
||||
|
||||
|
@ -396,6 +422,9 @@ public class EaglerAdapterImpl2 {
|
|||
masterVolumeNode = audioctx.createGain();
|
||||
masterVolumeNode.getGain().setValue(1.0f);
|
||||
masterVolumeNode.connect(audioctx.getDestination());
|
||||
musicVolumeNode = audioctx.createGain();
|
||||
musicVolumeNode.getGain().setValue(1.0f);
|
||||
musicVolumeNode.connect(audioctx.getDestination());
|
||||
|
||||
mouseEvents.clear();
|
||||
keyEvents.clear();
|
||||
|
@ -1949,18 +1978,24 @@ public class EaglerAdapterImpl2 {
|
|||
}
|
||||
|
||||
private static int playbackId = 0;
|
||||
private static int audioElementId = 0;
|
||||
private static final HashMap<String,AudioBufferX> loadedSoundFiles = new HashMap();
|
||||
private static AudioContext audioctx = null;
|
||||
private static GainNode masterVolumeNode = null;
|
||||
private static GainNode musicVolumeNode = null;
|
||||
private static float playbackOffsetDelay = 0.03f;
|
||||
|
||||
public static final void setPlaybackOffsetDelay(float f) {
|
||||
playbackOffsetDelay = f;
|
||||
}
|
||||
|
||||
|
||||
public static final void setMasterVolume(float f) {
|
||||
masterVolumeNode.getGain().setValue(f);
|
||||
}
|
||||
|
||||
public static final void setMusicVolume(float f) {
|
||||
musicVolumeNode.getGain().setValue(f);
|
||||
}
|
||||
|
||||
@Async
|
||||
public static native AudioBuffer decodeAudioAsync(ArrayBuffer buffer);
|
||||
|
@ -1979,8 +2014,8 @@ public class EaglerAdapterImpl2 {
|
|||
});
|
||||
}
|
||||
|
||||
private static final HashMap<Integer,AudioBufferSourceNodeX> activeSoundEffects = new HashMap();
|
||||
|
||||
private static final HashMap<Integer,AudioSourceNodeX> activeSoundEffects = new HashMap();
|
||||
|
||||
private static class AudioBufferX {
|
||||
private final AudioBuffer buffer;
|
||||
private AudioBufferX(AudioBuffer buffer) {
|
||||
|
@ -1988,16 +2023,32 @@ public class EaglerAdapterImpl2 {
|
|||
}
|
||||
}
|
||||
|
||||
private static class AudioBufferSourceNodeX {
|
||||
private final AudioBufferSourceNode source;
|
||||
private static class AudioSourceNodeX {
|
||||
private final PannerNode panner;
|
||||
private final GainNode gain;
|
||||
private AudioBufferSourceNodeX(AudioBufferSourceNode source, PannerNode panner, GainNode gain) {
|
||||
this.source = source;
|
||||
private AudioSourceNodeX(PannerNode panner, GainNode gain) {
|
||||
this.panner = panner;
|
||||
this.gain = gain;
|
||||
}
|
||||
}
|
||||
|
||||
private static class AudioBufferSourceNodeX extends AudioSourceNodeX {
|
||||
private final AudioBufferSourceNode source;
|
||||
private AudioBufferSourceNodeX(AudioBufferSourceNode source, PannerNode panner, GainNode gain) {
|
||||
super(panner, gain);
|
||||
this.source = source;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MediaElementAudioSourceNodeX extends AudioSourceNodeX {
|
||||
private final MediaElementAudioSourceNode source;
|
||||
private final HTMLAudioElement audio;
|
||||
private MediaElementAudioSourceNodeX(MediaElementAudioSourceNode source, HTMLAudioElement audio, PannerNode panner, GainNode gain) {
|
||||
super(panner, gain);
|
||||
this.source = source;
|
||||
this.audio = audio;
|
||||
}
|
||||
}
|
||||
|
||||
private static final AudioBuffer getBufferFor(String fileName) {
|
||||
AudioBufferX ret = loadedSoundFiles.get(fileName);
|
||||
|
@ -2012,11 +2063,29 @@ public class EaglerAdapterImpl2 {
|
|||
return ret.buffer;
|
||||
}
|
||||
public static final int beginPlayback(String fileName, float x, float y, float z, float volume, float pitch) {
|
||||
AudioBuffer b = getBufferFor(fileName);
|
||||
if(b == null) return -1;
|
||||
AudioBufferSourceNode s = audioctx.createBufferSource();
|
||||
s.setBuffer(b);
|
||||
s.getPlaybackRate().setValue(pitch);
|
||||
return beginPlayback(fileName, x, y, z, volume, pitch, false);
|
||||
}
|
||||
public static final int beginPlayback(String fileNamePre, float x, float y, float z, float volume, float pitch, boolean music) {
|
||||
if(fileNamePre.startsWith("/")) fileNamePre = fileNamePre.substring(1);
|
||||
String fileName = AssetRepository.fileNameOverrides.getOrDefault(fileNamePre, fileNamePre);
|
||||
AudioNode s;
|
||||
HTMLAudioElement audioElement = null;
|
||||
String lowerFileName = fileName.toLowerCase();
|
||||
boolean usingUrl = AssetRepository.fileNameOverrides.containsKey(fileNamePre) || lowerFileName.startsWith("http://") || lowerFileName.startsWith("https://") || lowerFileName.startsWith("blob:") || lowerFileName.startsWith("data:");
|
||||
if (usingUrl) {
|
||||
audioElement = (HTMLAudioElement) win.getDocument().createElement("audio");
|
||||
audioElement.setAutoplay(true);
|
||||
audioElement.setSrc(fileName);
|
||||
s = audioctx.createMediaElementSource(audioElement);
|
||||
audioElement.setPlaybackRate(pitch);
|
||||
} else {
|
||||
AudioBuffer b = getBufferFor(fileName);
|
||||
if(b == null) return -1;
|
||||
s = audioctx.createBufferSource();
|
||||
((AudioBufferSourceNode) s).setBuffer(b);
|
||||
((AudioBufferSourceNode) s).getPlaybackRate().setValue(pitch);
|
||||
}
|
||||
ChannelMergerNode c = audioctx.createChannelMerger(1);
|
||||
PannerNode p = audioctx.createPanner();
|
||||
p.setPosition(x, y, z);
|
||||
p.setMaxDistance(volume * 16f + 0.1f);
|
||||
|
@ -2030,69 +2099,132 @@ public class EaglerAdapterImpl2 {
|
|||
p.setOrientation(0f, 1f, 0f);
|
||||
GainNode g = audioctx.createGain();
|
||||
g.getGain().setValue(volume > 1.0f ? 1.0f : volume);
|
||||
s.connect(g);
|
||||
s.connect(c);
|
||||
c.connect(g);
|
||||
g.connect(p);
|
||||
p.connect(masterVolumeNode);
|
||||
s.start(0.0d, playbackOffsetDelay);
|
||||
p.connect(music ? musicVolumeNode : masterVolumeNode);
|
||||
if (!usingUrl) {
|
||||
((AudioBufferSourceNode) s).start(0.0d, playbackOffsetDelay);
|
||||
}
|
||||
final int theId = ++playbackId;
|
||||
activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, p, g));
|
||||
s.setOnEnded(new EventListener<MediaEvent>() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(MediaEvent evt) {
|
||||
activeSoundEffects.remove(theId);
|
||||
}
|
||||
|
||||
});
|
||||
if (usingUrl) {
|
||||
activeSoundEffects.put(theId, new MediaElementAudioSourceNodeX((MediaElementAudioSourceNode) s, audioElement, p, g));
|
||||
audioElement.addEventListener("canplay", new EventListener<Event>() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
if (activeSoundEffects.containsKey(theId)) {
|
||||
((MediaElementAudioSourceNodeX) activeSoundEffects.get(theId)).audio.play();
|
||||
}
|
||||
}
|
||||
});
|
||||
audioElement.addEventListener("ended", new EventListener<Event>() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
((MediaElementAudioSourceNodeX) activeSoundEffects.remove(theId)).audio.setSrc("");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
activeSoundEffects.put(theId, new AudioBufferSourceNodeX((AudioBufferSourceNode) s, p, g));
|
||||
((AudioBufferSourceNode) s).setOnEnded(new EventListener<MediaEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MediaEvent evt) {
|
||||
activeSoundEffects.remove(theId);
|
||||
}
|
||||
});
|
||||
}
|
||||
return theId;
|
||||
}
|
||||
public static final int beginPlaybackStatic(String fileName, float volume, float pitch) {
|
||||
AudioBuffer b = getBufferFor(fileName);
|
||||
if(b == null) return -1;
|
||||
AudioBufferSourceNode s = audioctx.createBufferSource();
|
||||
s.setBuffer(b);
|
||||
s.getPlaybackRate().setValue(pitch);
|
||||
return beginPlaybackStatic(fileName, volume, pitch, false);
|
||||
}
|
||||
public static final int beginPlaybackStatic(String fileNamePre, float volume, float pitch, boolean music) {
|
||||
if(fileNamePre.startsWith("/")) fileNamePre = fileNamePre.substring(1);
|
||||
String fileName = AssetRepository.fileNameOverrides.getOrDefault(fileNamePre, fileNamePre);
|
||||
AudioNode s;
|
||||
HTMLAudioElement audioElement = null;
|
||||
String lowerFileName = fileName.toLowerCase();
|
||||
boolean usingUrl = AssetRepository.fileNameOverrides.containsKey(fileNamePre) || lowerFileName.startsWith("http://") || lowerFileName.startsWith("https://") || lowerFileName.startsWith("blob:") || lowerFileName.startsWith("data:");
|
||||
if (usingUrl) {
|
||||
audioElement = (HTMLAudioElement) win.getDocument().createElement("audio");
|
||||
audioElement.setAutoplay(true);
|
||||
audioElement.setSrc(fileName);
|
||||
s = audioctx.createMediaElementSource(audioElement);
|
||||
audioElement.setPlaybackRate(pitch);
|
||||
} else {
|
||||
AudioBuffer b = getBufferFor(fileName);
|
||||
if(b == null) return -1;
|
||||
s = audioctx.createBufferSource();
|
||||
((AudioBufferSourceNode) s).setBuffer(b);
|
||||
((AudioBufferSourceNode) s).getPlaybackRate().setValue(pitch);
|
||||
}
|
||||
GainNode g = audioctx.createGain();
|
||||
g.getGain().setValue(volume > 1.0f ? 1.0f : volume);
|
||||
s.connect(g);
|
||||
g.connect(masterVolumeNode);
|
||||
s.start(0.0d, playbackOffsetDelay);
|
||||
g.connect(music ? musicVolumeNode : masterVolumeNode);
|
||||
if (!usingUrl) {
|
||||
((AudioBufferSourceNode) s).start(0.0d, playbackOffsetDelay);
|
||||
}
|
||||
final int theId = ++playbackId;
|
||||
activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, null, g));
|
||||
s.setOnEnded(new EventListener<MediaEvent>() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(MediaEvent evt) {
|
||||
activeSoundEffects.remove(theId);
|
||||
}
|
||||
|
||||
});
|
||||
return playbackId;
|
||||
if (usingUrl) {
|
||||
activeSoundEffects.put(theId, new MediaElementAudioSourceNodeX(((MediaElementAudioSourceNode) s), audioElement, null, g));
|
||||
audioElement.addEventListener("canplay", new EventListener<Event>() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
if (activeSoundEffects.containsKey(theId)) {
|
||||
((MediaElementAudioSourceNodeX) activeSoundEffects.get(theId)).audio.play();
|
||||
}
|
||||
}
|
||||
});
|
||||
audioElement.addEventListener("ended", new EventListener<Event>() {
|
||||
@Override
|
||||
public void handleEvent(Event evt) {
|
||||
((MediaElementAudioSourceNodeX) activeSoundEffects.remove(theId)).audio.setSrc("");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
activeSoundEffects.put(theId, new AudioBufferSourceNodeX(((AudioBufferSourceNode) s), null, g));
|
||||
((AudioBufferSourceNode) s).setOnEnded(new EventListener<MediaEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MediaEvent evt) {
|
||||
activeSoundEffects.remove(theId);
|
||||
}
|
||||
});
|
||||
}
|
||||
return theId;
|
||||
}
|
||||
public static final void setPitch(int id, float pitch) {
|
||||
AudioBufferSourceNodeX b = activeSoundEffects.get(id);
|
||||
if(b != null) {
|
||||
b.source.getPlaybackRate().setValue(pitch);
|
||||
AudioSourceNodeX a = activeSoundEffects.get(id);
|
||||
if(a != null) {
|
||||
if (a instanceof AudioBufferSourceNodeX) {
|
||||
((AudioBufferSourceNodeX) a).source.getPlaybackRate().setValue(pitch);
|
||||
} else if (a instanceof MediaElementAudioSourceNodeX) {
|
||||
((MediaElementAudioSourceNodeX) a).audio.setPlaybackRate(pitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static final void setVolume(int id, float volume) {
|
||||
AudioBufferSourceNodeX b = activeSoundEffects.get(id);
|
||||
if(b != null) {
|
||||
b.gain.getGain().setValue(volume > 1.0f ? 1.0f : volume);
|
||||
if(b.panner != null) b.panner.setMaxDistance(volume * 16f + 0.1f);
|
||||
AudioSourceNodeX a = activeSoundEffects.get(id);
|
||||
if(a != null) {
|
||||
a.gain.getGain().setValue(volume > 1.0f ? 1.0f : volume);
|
||||
if(a.panner != null) a.panner.setMaxDistance(volume * 16f + 0.1f);
|
||||
}
|
||||
}
|
||||
public static final void moveSound(int id, float x, float y, float z, float vx, float vy, float vz) {
|
||||
AudioBufferSourceNodeX b = activeSoundEffects.get(id);
|
||||
if(b != null && b.panner != null) {
|
||||
b.panner.setPosition(x, y, z);
|
||||
//b.panner.setVelocity(vx, vy, vz);
|
||||
AudioSourceNodeX a = activeSoundEffects.get(id);
|
||||
if(a != null && a.panner != null) {
|
||||
a.panner.setPosition(x, y, z);
|
||||
//a.panner.setVelocity(vx, vy, vz);
|
||||
}
|
||||
}
|
||||
public static final void endSound(int id) {
|
||||
AudioBufferSourceNodeX b = activeSoundEffects.get(id);
|
||||
if(b != null) {
|
||||
b.source.stop();
|
||||
AudioSourceNodeX a = activeSoundEffects.get(id);
|
||||
if(a != null) {
|
||||
if (a instanceof AudioBufferSourceNodeX) {
|
||||
((AudioBufferSourceNodeX) a).source.stop();
|
||||
} else if (a instanceof MediaElementAudioSourceNodeX) {
|
||||
((MediaElementAudioSourceNodeX) a).audio.pause();
|
||||
((MediaElementAudioSourceNodeX) a).audio.setSrc("");
|
||||
}
|
||||
activeSoundEffects.remove(id);
|
||||
}
|
||||
}
|
||||
|
@ -3919,7 +4051,7 @@ public class EaglerAdapterImpl2 {
|
|||
}
|
||||
}
|
||||
|
||||
private static final int fragmentSize = 16384;
|
||||
private static final int fragmentSize = 65536;
|
||||
|
||||
public static final void serverLANWritePacket(String peer, byte[] data) {
|
||||
if (data.length > fragmentSize) {
|
||||
|
|
36840
stable-download/Offline_Download_Version.html
vendored
36840
stable-download/Offline_Download_Version.html
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user