4

When I click, the following code leads the two sounds to be played not simultaneously, but sequentially. Why are they not played simultaneously?

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mytextview=(TextView) findViewById(R.id.textview);
    mytextview.setOnClickListener(this);

    sp=(SoundPool) new SoundPool(8,0x00000003,1);
    upSound=sp.load(this, R.raw.sound1, 1);
    downSound=sp.load(this, R.raw.sound2, 1);
}

    @Override
public void onClick(View v) {
    sp.play(downSound, VOLUME, VOLUME, 1, 0, 1);
    sp.play(upSound, VOLUME, VOLUME, 1, 0, 2);
}
Doug Bradshaw
  • 1,452
  • 1
  • 16
  • 20

2 Answers2

7

one very important piece of information that I don't see a lot when working with sound files: DO NOT USE WAV's !!!

you'll see weird behavior, which can vary from phone to phone.

ALWAYS USE OGG !!!

Someone Somewhere
  • 23,475
  • 11
  • 118
  • 166
  • rly helped me ! thx a lot ! with .wav its actually was behaving weird. Sometimes it was playing , sometimes no sound at all. After converting it to ogg using some online converters, its working ^^ thx – Rohit Mar 17 '12 at 09:21
0

Possible duplicate of this question. In an answer to that question, there is a link to an answer to yet another question that may be of some help, in case you are still looking...

Community
  • 1
  • 1
Jason Plank
  • 2,336
  • 5
  • 31
  • 40