我正在尝试使用 SoundManager 随机播放 30 秒的声音片段,同时启动由 onTouch 事件触发的动画序列(闪烁图形)。无论出于何种原因,在播放大约 5 秒后,声音片段就会被剪掉,我不知道为什么。有什么想法吗?
同样经过测试,似乎直到最初的 onTouch 事件后一分钟左右才会播放。
public class Soundboard extends Activity {
private SoundManager mSoundManager;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mSoundManager = new SoundManager();
mSoundManager.initSounds(getBaseContext());
mSoundManager.addSound(0, R.raw.sound0);
mSoundManager.addSound(1, R.raw.sound1);
mSoundManager.addSound(2, R.raw.sound2);
mSoundManager.addSound(3, R.raw.sound3);
};
public boolean onTouchEvent(MotionEvent evt){
Random r = new Random();
int x = r.nextInt(3);
switch (evt.getAction())
{
case MotionEvent.ACTION_DOWN:
mSoundManager.playSound(x);
startAnimating();
return super.onTouchEvent(evt);
case MotionEvent.ACTION_UP:
break;
default:
break;
}
return true;
}
private void startAnimating() {
ImageView wiub_screen01 = (ImageView) findViewById(R.id.wiub_screen01);
Animation fadein01 = AnimationUtils.loadAnimation(this, R.anim.fade_in01);
wiub_screen01.startAnimation(fadein01);
ImageView wiub_screen00 = (ImageView) findViewById(R.id.wiub_screen00);
Animation fadein00 = AnimationUtils.loadAnimation(this, R.anim.fade_in00);
wiub_screen00.startAnimation(fadein00);
}
}