eclipse 在 Android 上做一个音频循环

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2684948/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:38:30  来源:igfitidea点击:

Doing an audio loop on Android

javaandroideclipseaudiomedia

提问by James Rattray

I have a track I want to play 'megadeth', I'm calling it by:

我有一个曲目我想播放“megadeth”,我通过以下方式调用它:

    final MediaPlayer mp = MediaPlayer.create(this, R.raw.megadeth);

And playing it by using 'mp.start'.

并使用“mp.start”播放它。

And I just want to know, how can I get this audio mp3 to loop?

我只想知道,我怎样才能让这个音频 mp3 循环播放?

回答by Tobi Akerele

Before adding

添加前

mp.start();

mp.start();

Add

添加

MediaPlayer mp = MediaPlayer.create(MainMenu.this, R.raw.megadeth);
    mp.setLooping(true);

the mp.setLooping(true); automatically allows the raw file to be used over and over again.

mp.setLooping(true); 自动允许一遍又一遍地使用原始文件。