Java Eclipse 使用源文件夹导出游戏
Java Eclipse exporting game with source folder
我正在尝试用一堆音乐导出我的游戏。当我导出带有音乐的游戏时(文件大小为 300mb(资源文件夹大小约为 300mb))
当我 运行 罐子时,我听不到任何声音。我尝试使用 cmd 它显示以下错误:
有帮助吗?
编辑
声音管理器Class:
package com.memequickie.sound;
import java.io.File;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
public class SoundManager {
Clip clip;
public boolean playSound(File sound) {
boolean ended = false;
try {
clip = AudioSystem.getClip();
clip.open(AudioSystem.getAudioInputStream(sound));
clip.start();
if(clip.getMicrosecondLength() == clip.getMicrosecondPosition())
{
ended = true;
}
} catch(Exception e) {
System.out.println("Error with playing sound.");
e.printStackTrace();
}
return ended;
}
public void stopSound() {
clip.stop();
}
}
编辑
我尝试了输入流,但仍然无法正常工作。
AudioSystem.getAudioInputStream(<strong>文件</strong>)
期望 Music6.wav
作为真实文件,不是作为压缩文件在 JAR.
中
如果你想在 JAR 中传送你的音频文件,你必须使用 AudioSystem.getAudioInputStream(<strong>InputStream</strong>)
audio file as InputStream
包裹在 BufferedInputStream
中。
我正在尝试用一堆音乐导出我的游戏。当我导出带有音乐的游戏时(文件大小为 300mb(资源文件夹大小约为 300mb))
当我 运行 罐子时,我听不到任何声音。我尝试使用 cmd 它显示以下错误:
有帮助吗?
编辑
声音管理器Class:
package com.memequickie.sound;
import java.io.File;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
public class SoundManager {
Clip clip;
public boolean playSound(File sound) {
boolean ended = false;
try {
clip = AudioSystem.getClip();
clip.open(AudioSystem.getAudioInputStream(sound));
clip.start();
if(clip.getMicrosecondLength() == clip.getMicrosecondPosition())
{
ended = true;
}
} catch(Exception e) {
System.out.println("Error with playing sound.");
e.printStackTrace();
}
return ended;
}
public void stopSound() {
clip.stop();
}
}
编辑
我尝试了输入流,但仍然无法正常工作。
AudioSystem.getAudioInputStream(<strong>文件</strong>)
期望 Music6.wav
作为真实文件,不是作为压缩文件在 JAR.
如果你想在 JAR 中传送你的音频文件,你必须使用 AudioSystem.getAudioInputStream(<strong>InputStream</strong>)
audio file as InputStream
包裹在 BufferedInputStream
中。