开发者

how can i play mp3 in andengine?

开发者 https://www.devze.com 2023-04-05 16:54 出处:网络
i want to play sound whenmy condition is matched, but i don\'t how开发者_如何学JAVA can i play sound or music in andengine?

i want to play sound when my condition is matched, but i don't how开发者_如何学JAVA can i play sound or music in andengine?

help me to find my solution.

your answer will be awarded.


You can obviously use the MediaPlayer in AndEngine too, it works fine as it does in Android, because AndEngine is also a part of Android itself.

You can keep your file in res/raw/anyfile.mp3

MediaPlayer mediaPlayer = MediaPlayer
                .create(getApplicationContext(), R.raw.anyfile);
        try {
            mediaPlayer.start();
            mediaPlayer.setLooping(true);
        } catch (Exception e) {
            e.printStackTrace();
        }


though i haven't perform a sound task, but hope this tutorial link will help u,,

http://www.droidnova.com/creating-sound-effects-in-android-part-1,570.html

0

精彩评论

暂无评论...
验证码 换一张
取 消