What's the difference between LibGDX Sound and Music types?

只谈情不闲聊 提交于 2019-12-13 16:59:37

问题


What is difference between Sound and Music types in LibGDX? This worked both on desktop and Android:

Music gameMusic = Gdx.audio.newMusic(Gdx.files.internal("sound/gamemusic.mp3"));
gameMusic.play();:

Sound gameMusic = Gdx.audio.newSound(Gdx.files.internal("sound/gamemusic.mp3"));
gameMusic.play();

回答1:


Music is streamed, while Sound is loaded into memory. (Because Android with libgdx has limit of 1mb file for 'sound', Music can be of greater size)

It is said so here:

https://github.com/libgdx/libgdx/wiki/Sound-effects

https://github.com/libgdx/libgdx/wiki/Streaming-music

And according to another question on SO, you must wait a frame before you can play a Sound directly after loading: No Sound in Android Application with Libgdx



来源:https://stackoverflow.com/questions/24305630/whats-the-difference-between-libgdx-sound-and-music-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!