panthro
panthro

Reputation: 24061

Why is my mp3 being compressed?

Im trying to open an mp3 in soundpool via an id with load, ive also tried doing it via a file descriptor.

I always get the same exception:

This file can not be opened as a file descriptor; it is probably compressed

Why is my mp3 being compressed?

Here is the soundpool code:

mySoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
try { mySoundPool.load(this, R.raw.drum, 1);
   } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Log.e(TAG, "", e);
    }

Upvotes: 2

Views: 315

Answers (1)

Dan J
Dan J

Reputation: 25673

MP3 is a compressed file format, so your MP3 file is already compressed. As wikipedia says:

MP3, is a patented digital audio encoding format using a form of lossy data compression

This Stackoverflow question suggests that you should use WAV or OGG support on Android, and offers an alternative way of playing MP3s.

The SoundPool API docs do imply MP3 support, so I'm not sure what is going wrong here. I suggest you try testing with some other MP3 files, and also test converting your existing MP3 to WAV/OGG formats to test that too.

You'll need to rename it as Android resources don't include the file extension. Make sure you check if you have another file in res\raw with the same name but a different file extension, as that could cause problems.

Upvotes: 1

Related Questions