如何在 andengine 中播放 mp3?

发布于 2024-12-05 11:02:12 字数 87 浏览 4 评论 0原文

我想在我的条件匹配时播放声音,但我不知道如何在andengine中播放声音或音乐?

帮助我找到我的解决方案。

你的回答将被奖励。

i want to play sound when my condition is matched, but i don't how can i play sound or music in andengine?

help me to find my solution.

your answer will be awarded.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

£烟消云散 2024-12-12 11:02:12

显然,您也可以在 AndEngine 中使用 MediaPlayer,它可以像在 Android 中一样正常工作,因为 AndEngine 是也是Android本身的一部分。

您可以将文件保存在 res/raw/anyfile.mp3

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

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();
        }
眼眸里的那抹悲凉 2024-12-12 11:02:12

虽然我还没有执行声音任务,但希望本教程链接对您有所帮助,

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文