Playback for AMR file format

1.4k Views Asked by At

When I try to play the track with AMR file format. It throws a warning

Permission failure: android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK

and error from libOpenSLES

AudioSfDecoder::onPrepare: Could not find a supported audio track.

I tried setting the permission in manifest file.

    <!-- Allows an application to use any media decoder when decoding for playback
         @hide -->
    <permission android:name="android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK"
         android:protectionLevel="signatureOrSystem"
         android:label="@string/permlab_anyCodecForPlayback"
         android:description="@string/permdesc_anyCodecForPlayback" />

But still throws the same error.

Am I setting the permission correctly? Could anyone help me out, what am I missing.

1

There are 1 best solutions below

0
On

AMR is not supported with the NDK on many devices. You could use an external AMR library. Use the PCM recorder/player and encode and decode manually with opencore-amr.

This works fine for me.

Towards your permission issue:

android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK

is no official permission, so why do you use this here? There are no codec related permissions on Android I know of.

Important is only Record_Audio for Microphone access.