Playing recorded audio

Discussion in 'Application Development' started by jon21569, Oct 31, 2008.

  1. jon21569

    jon21569 Member
    16

    Aug 10, 2008
    23
    7
    16
    On the G1 I am attempting to play audio that has been recorded.

    Here is the code I am using to record audio.

    ///////////
    m_recorder = new MediaRecorder();
    m_recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    m_recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    m_recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    m_canvas.m_context.getFilesDir().mkdirs();
    String path = m_context.getFilesDir() + "/recorded.amr";
    m_recorder.setOutputFile(path);
    m_recorder.prepare();
    m_recorder.start();
    m_iRecordState = kRecordState_Recording;
    ////////////

    I have tried several ways of playing the recorded audio, but so far without success. Here are various ways I have attempted to play the audio.

    /////////
    Uri uri = Uri.fromFile(getFileStreamPath("recorded.amr") );
    m_mediaPlayer = MediaPlayer.create( m_context, uri );
    m_mediaPlayer.start();
    //////////
    Uri uri = Uri.fromFile(getFileStreamPath(m_context.getFilesDir() + "recorded.amr") );
    m_mediaPlayer = MediaPlayer.create(m_context, uri );
    m_mediaPlayer.start();
    ///////////
    String path = m_context.getFilesDir() + "/recorded.amr";
    m_mediaPlayer.setDataSource(path);
    m_mediaPlayer.prepare();
    m_mediaPlayer.start();
    ///////////

    Has anyone had success playing recorded audio?
     

    Advertisement

Share This Page

Loading...