Question

I am working on a game that plays audio. The sounds play fine on my Samsung device and an HTC device. However, the sounds do not play on a Motorola Droid X2.

To initialize my SoundPool:

static SoundPool sp;
sp = new SoundPool(8, AudioManager.STREAM_MUSIC, 0);
sp.load(context, resource_id, 1);

To play a sound:

sp.play(resource_id, 1.0f, 1.0f, 0, 0, 1.0f);

I have tried searching for any bugs that may exist for Motorola devices and the SoundPool but have not found anything useful. Any and all help is appreciated.

I am loading five MP3 files, all less than 20kb each.

I create a skeleton project and included only the code below in the MainActivity, with the same results. Only loading one 12kb MP3 file, from the Resources class.

super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    SoundPool sp = new SoundPool(16, AudioManager.STREAM_MUSIC, 0);
    int name = sp.load(this.getApplicationContext(), R.raw.brickhit,1);
        try {
            Thread.sleep(10000);
            Log.d("mark","sleeping....");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    sp.play(name, 1.0f, 1.0f, 1, -1, 1.0f);
Was it helpful?

Solution 2

After some experimentation it turns out that Motorola Droid X2's will not play MP3 files through the SoundPool, at least not when loaded as above. I switched to .ogg format and the sounds are playing as expected.

OTHER TIPS

I didn't experience the problem before, but maybe the stream count could be a problem like described here: Android Soundpool problems

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top