i use MediaRecorder to record audio ,but i find that it can't record
audio in first 0.7s.

plz help me to solve this problem.
my code like this:

        public void init() {
                try {
                mediaRecorder = new MediaRecorder();
                mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
                
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
                if (file == null) {
                        File rootDir = 
Environment.getExternalStorageDirectory();
                        file = File.createTempFile(PREFIX, EXTENSION, rootDir);
                }
                mediaRecorder.setOutputFile(file.getAbsolutePath());
                mediaRecorder.prepare();
                } catch (Exception ex) {
                        Log.e(SysConst.TAG, "init", ex);
                }
        }

        public void start() {
                startRecording();
        }

        public void free() {
                stopRecording();
        }

        public void startRecording() {
                        mediaRecorder.start();
        }

        /**
         * This method stops recording
         */
        private void stopRecording() {
                mediaRecorder.stop();
                mediaRecorder.release();

        }
--------------------------------------------

                        MediaRecordUtil reco = new MediaRecordUtil();
                        reco.init();
                        reco.start();
                        mRecoThread = new VoiceRecoThread(4000);
                        mRecoThread.start();
                        mRecoThread.join();
                        reco.free();

the amr data in first 0.7s like this

00000030h: E7 BA F0 00 00 00 C0 00 00 00 00 00 00 00 00 00 ;
绾?..?........
00000040h: 00 00 00 00 00 00 3C 55 00 88 B6 66 79 E1 E0 01 ; ......<U.��
fy徉.
00000050h: E7 CF F0 00 00 00 80 00 00 00 00 00 00 00 00 00 ; 缦?..
�.........
00000060h: 00 00 00 00 00 00 3C 48 F9 1F 96 66 79 E1 E0 01 ; ......<H?�f
y徉.
00000070h: E7 8A F0 00 00 00 C0 00 00 00 00 00 00 00 00 00 ;
��?..?........
00000080h: 00 00 00 00 00 00 3C 54 FD 1F B6 66 79 E1 E0 01 ; ......<T?�f
y徉.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to