LIBGDX: How can i tell when a sound has finished playing?

℡╲_俬逩灬. 提交于 2019-12-08 14:44:12

问题


The Sound API seems to be missing a function to indicate that a sound is finished playing. Is there some other way of finding out if the sound is done?


回答1:


Not without submitting a patch to libgdx as far as I know the underlying Sound Backends for both OpenAL and Android don't even track the information internally, though the Music API has an isPlaying() function and getPosition() function as per the documentation.




回答2:


just set this

sound.setLooping(false);

this way it will not run again and again.

and to check whether sound is playing or not do this.

make a boolean variable

boolean soundplaying;

in render method do this

if(sound.isPlaying()){
soundplaying =true
}

and make a log

gdx.app.log("","sound"+soundplaying);


来源:https://stackoverflow.com/questions/11704733/libgdx-how-can-i-tell-when-a-sound-has-finished-playing

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