【发布时间】:2013-12-14 15:05:18
【问题描述】:
我想使用 MediaPlayer 循环播放该曲目,但它在最后会产生奇怪的故障噪音,该曲目似乎在 Audacity 中运行良好,它使用 .OGG,我尝试使用 SoundPool,但我似乎无法正常工作.
SoundPool pool = new SoundPool(1, AudioManager.STREAM_MUSIC,0);
AssetFileDescriptor lfd = this.getResourc es().openRawResourceFd(R.raw.dishwasherloop);
//mediaPlayer = new MediaPlayer();
try
{
//mediaPlayer.setDataSource(lfd.getFileDescriptor(),lfd.getStartOffset(), lfd.getLength());
//mediaPlayer.prepare();
//mediaPlayer.start();
int dish = pool.load(lfd,1);
pool.play(dish,0.5f,0.5f,1,-1,1.0f);
soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener()
{
public void onLoadComplete(SoundPool soundPool, int sampleId,
int status) {
loaded = true;
}
});
int soundID = soundPool.load(this, R.raw.dishwasherloop, 1);
soundPool.play(soundID, 0.5f, 0.5f, 1, 0, 1f);
【问题讨论】:
标签: android loops media-player soundpool