[英]Android Studio with libGdx(Java) - Music work on android emulator but not on desktop
Here's my code: 这是我的代码:
music = Gdx.audio.newMusic(Gdx.files.internal("music.mp3"));
music.setLooping(true);
music.setVolume(0.1f);
music.play();
When i run the app on android emulator everything work as it should and when i run the app on desktop there's no music. 当我在android模拟器上运行该应用程序时,一切正常,当我在桌面上运行该应用程序时,没有音乐。 What should i do?
我该怎么办?
After another searching, I finally found an answer! 经过又一次搜索,我终于找到了答案! this happens because I have on my computer an username that isn't in english.
发生这种情况是因为我在计算机上使用了非英语的用户名。 All i needed to do was to add
System.setProperty("user.name","seconduser");
我要做的就是添加
System.setProperty("user.name","seconduser");
to the DesktopLauncher code. 到DesktopLauncher代码。 The final code should look like this:
最终代码应如下所示:
public class DesktopLauncher {
public static void main (String[] arg) {
System.setProperty("user.name","seconduser");
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
new LwjglApplication(new GameName(), config);
}
Hope it will help someone else. 希望它会帮助别人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.