setDataSourceFD failed.: status=0x80000000 while playing audio

0

I am trying to split an recorded audio file into smaller chunks if the audio duration is more than 1 minute into smaller chunks of 1 minute each and treat them as individual audio files in Android.

I record my audio by doing the following:-

MediaRecorder mAudioRecorder = new MediaRecorder();
    mAudioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mAudioRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    mAudioRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
    mAudioRecorder.setOutputFile(outputFile);
    startRecording();

When I record the above audio, it is recorded and played properly. Now to clip this audio I am using [this][1] library.

    CheapSoundFile cheapSoundFile = CheapSoundFile.create(in_file_path,listner);

    int mSampleRate = cheapSoundFile.getSampleRate();

    int mSamplesPerFrame = cheapSoundFile.getSamplesPerFrame();

    int startFrame = Utilities.secondsToFrames(5.0,mSampleRate, mSamplesPerFrame);

    int endFrame = Utilities.secondsToFrames(30.0, mSampleRate,mSamplesPerFrame);

String outputFileDirectory = Environment.getExternalStorageDirectory().getAbsolutePath() + this.getString(R.string.recording_folder);

                try
                {
                    File dir = new File(outputFileDirectory);
                    if (!dir.exists())
                    {
                        dir.mkdirs();
                    }
                    mFileNumber++;
                    outputFile = outputFileDirectory + "Clip_" + String.valueOf(mFileNumber) + this.getString(R.string.recording_mp3);
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }
    cheapSoundFile.WriteFile(outputFile , startFrame, endFrame-startFrame);

    final CheapSoundFile.ProgressListener listener = new CheapSoundFile.ProgressListener() {
        public boolean reportProgress(double frac) {

        return true; 
        }
    };

Then further, I play the clipped file as :-

MediaPlayer mediaPlayer = new MediaPlayer();
                try
                {
                    if (mediaPlayer != null)
                    {
                        mediaPlayer.setDataSource(outputFile);
                        mediaPlayer.prepare();
                    }
                    mediaPlayer.start();

                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }

But however, I get an exception while playing the clipped audio which says :-

setDataSourceFD failed.: status=0x80000000

Any help on resolving this issue is highly appreciated. Thank you.

split
audio-recording
seekbar
android-mediarecorder
asked on Stack Overflow Feb 7, 2019 by user3034944

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0