如何在Android中恢复音频?

时间:2015-07-01 06:46:18

标签: android audio-recording

我已在我的应用程序中实现了录音功能。我能够录制音频并停止录制。但我无法恢复录音。

我试过录制音频的以下片段

recordIconImage.setOnClickListener(new OnClickListener(){

        @Override
        public void onClick(View v) {

            File parentFile = new File(Environment
                    .getExternalStorageDirectory(),
                    "/TafeRecordings/AudioRecordings/");
            parentFile.mkdirs();

            if (!parentFile.exists()) {

                if (!parentFile.mkdirs()) {

                    Toast.makeText(getActivity(),
                            "Failed to create directory MyCameraImage.",
                            Toast.LENGTH_LONG).show();

                    Log.d("MyCameraVideo",
                            "Failed to create directory MyCameraImage.");
                }
            }
            mediaFile = new File(parentFile.getPath(), "Audio" + ".3gp");

            audioRecorder = new MediaRecorder();


            try {

                audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                audioRecorder
                        .setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
                audioRecorder
                        .setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
                audioRecorder.setOutputFile(mediaFile.getAbsolutePath());
                audioRecorder.prepare();
                audioRecorder.start();
            } catch (IllegalStateException e) {
                e.printStackTrace();

            } catch (IOException e) {

            }

        }
    });

0 个答案:

没有答案