Playing recorded audio


Last Updated:

  1. jon21569

    jon21569 Member This Topic's Starter

    Joined:
    Aug 10, 2008
    Messages:
    23
    Likes Received:
    7
    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...