Use vanilla sound engine to play render success sound (fixes #286)
This commit is contained in:
@@ -19,7 +19,6 @@ import com.replaymod.render.gui.GuiRenderingDone;
|
||||
import com.replaymod.render.gui.GuiVideoRenderer;
|
||||
import com.replaymod.render.metadata.MetadataInjector;
|
||||
import com.replaymod.render.mixin.WorldRendererAccessor;
|
||||
import com.replaymod.render.utils.SoundHandler;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||
import com.replaymod.replaystudio.pathing.path.Path;
|
||||
@@ -29,6 +28,7 @@ import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import com.mojang.blaze3d.platform.GLX;
|
||||
import net.minecraft.client.gl.Framebuffer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.crash.CrashException;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
@@ -422,7 +422,7 @@ public class VideoRenderer implements RenderInfo {
|
||||
}
|
||||
}
|
||||
|
||||
new SoundHandler().playRenderSuccessSound();
|
||||
MCVer.playSound(new Identifier("replaymod", "render_success"));
|
||||
|
||||
try {
|
||||
if (!hasFailed() && ffmpegWriter != null) {
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.replaymod.render.utils;
|
||||
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.Clip;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class SoundHandler {
|
||||
|
||||
private final Identifier successSoundLocation = new Identifier("replaymod", "render_success.wav");
|
||||
|
||||
public void playRenderSuccessSound() {
|
||||
playSound(successSoundLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays a <b>.wav</b> Sound from a ResourceLocation. This method does <b>not</b> respect Game Settings like Audio Volume.
|
||||
* @param loc The Sound File's ResourceLocation
|
||||
*/
|
||||
public void playSound(Identifier loc) {
|
||||
try {
|
||||
InputStream is = MCVer.getMinecraft().getResourceManager().getResource(loc).getInputStream();
|
||||
byte[] bytes = IOUtils.toByteArray(is);
|
||||
is.close();
|
||||
AudioInputStream ais = AudioSystem.getAudioInputStream(new ByteArrayInputStream(bytes));
|
||||
|
||||
Clip clip = AudioSystem.getClip();
|
||||
clip.open(ais);
|
||||
clip.start();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user