Android AAC format

I have a problem with audio on Android.

Short question:

I need to play and record aac audio on all Android devices. I found this to be possible starting with API 10, but on my BLU device (2.3.5) it works using MediaRecorderand MediaPlayer. But on HTC Nexus One, this will not work. Do you have any suggestions?

Long Term Question:

To record and play audio in AAC format, I use the following code. It's pretty simple and stupid, but it works for testing.

String pathForAppFiles = getFilesDir()
                .getAbsolutePath();
        pathForAppFiles += "/bla.mp4";
        if (audioRecorder == null) {

            File file = new File(pathForAppFiles);
            if (file.exists())
                file.delete();

            audioRecorder = new MediaRecorder();

            audioRecorder
                    .setAudioSource(MediaRecorder.AudioSource.MIC);

            audioRecorder
                    .setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

            audioRecorder
                    .setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

            audioRecorder.setOutputFile(pathForAppFiles);

            try {
                audioRecorder.prepare();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            audioRecorder.start();

        } else {
            audioRecorder.stop();
            audioRecorder.release();
            audioRecorder = null;

            new AudioUtils().playSound(pathForAppFiles);
        }

new AudioUtils().playSound(pathForAppFiles); - Creates MediaPlayer and plays sound from a file;

To make it work on nexus, I tried aac-decoder - it does not play the file to the end (it only plays 6 seconds out of a 10 second file). And it does not play the sound recorded by the above code.

FFmpeg, , .

- ?

+5
1

, MP3, (, Kindle Fire) aac .

: - - MP3. MP3 .

+1

All Articles