mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
- Fix for the Alternate Sound System by kevlahnota
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
package forge.sound;
|
package forge.sound;
|
||||||
|
|
||||||
|
import com.google.common.io.Files;
|
||||||
|
import com.sipgate.mp3wav.Converter;
|
||||||
|
|
||||||
import javax.sound.sampled.*;
|
import javax.sound.sampled.*;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -69,7 +73,8 @@ public class AltSoundSystem extends Thread {
|
|||||||
|
|
||||||
AudioInputStream audioInputStream = null;
|
AudioInputStream audioInputStream = null;
|
||||||
try {
|
try {
|
||||||
audioInputStream = AudioSystem.getAudioInputStream(soundFile);
|
ByteArrayInputStream bis = new ByteArrayInputStream(Converter.convertFrom(Files.asByteSource(soundFile).openStream()).toByteArray());
|
||||||
|
audioInputStream = AudioSystem.getAudioInputStream(bis);
|
||||||
} catch (UnsupportedAudioFileException e) {
|
} catch (UnsupportedAudioFileException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
@@ -82,8 +87,21 @@ public class AltSoundSystem extends Thread {
|
|||||||
SourceDataLine audioLine = null;
|
SourceDataLine audioLine = null;
|
||||||
DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
|
DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
|
||||||
|
|
||||||
|
Mixer.Info selectedMixer = null;
|
||||||
|
|
||||||
|
for (Mixer.Info mixerInfo : AudioSystem.getMixerInfo()) {
|
||||||
|
Mixer mixer = AudioSystem.getMixer(mixerInfo);
|
||||||
|
if (mixer.isLineSupported(info)) {
|
||||||
|
selectedMixer = mixerInfo;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedMixer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
audioLine = (SourceDataLine) AudioSystem.getLine(info);
|
audioLine = AudioSystem.getSourceDataLine(format, selectedMixer);
|
||||||
audioLine.open(format);
|
audioLine.open(format);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user