所以我有大约 6.5 秒长的声音,当我用 soundpool 播放它时它只播放 5 秒......我尝试使用 mediaplayer 但它对于这种应用程序来说太慢了。 声音池代码:
SoundPool sp;
OnCreate
sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
dub1s = sp.load(this, R.raw.dub1, 1);
Button
if (dub1s != 0)
sp.play(dub1s, 1, 1, 0, 0, 1);
}
最佳答案
尝试使用以下加载函数。
public int load (FileDescriptor fd, long offset, long length, int priority)
第三个参数是声音的长度。 比如说,你正在阅读一个文件
FileInputStream in = new FileInputStream(new File(soundFile));
load() 应该是这样的
sp.load(in.getFD(), start, length, 0);
关于java - 增加音池持续时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13650642/