Android 4.4.2 MediaPlayer API failed to play mp3 OMXCodec error

Having some bunches of E/OMXCodec error? That saying unable to playback your audio files?
Well i had been struggle with the same error. My situation is to play an MP3 file with
Android MediaPlayer API. The API works fine in my android 4.0 and 4.2 that plays
the alarm sound.

But it fails in my newer phones, which runs android 4.4.2. So i googled and found out that the MP3
also could be played with Ringtone and RingtoneManager.

Snippet:

Uri u = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/" + R.raw.kring);
Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), u);
ringtone.play();

Comments