Android. Playing multiple sounds using SoundManager
Posted
by Jerry
on Stack Overflow
See other posts from Stack Overflow
or by Jerry
Published on 2010-06-14T16:42:38Z
Indexed on
2010/06/14
17:02 UTC
Read the original article
Hit count: 199
Shown are a few lines of code. If I play a single sound, it runs fine. Adding a second sound causes it to crash. Any advice is appreciated.
private SoundManager mSoundManager;
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sos);
mSoundManager = new SoundManager();
mSoundManager.initSounds(getBaseContext());
mSoundManager.addSound(1,R.raw.dit);
mSoundManager.addSound(1,R.raw.dah);
Button SoundButton = (Button)findViewById(R.id.SoundButton);
SoundButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(1);
mSoundManager.playSound(2);
}
});
}
© Stack Overflow or respective owner