async stopRecordingAndEnablePlayback() {
    this.setState({
      playStatus: 'LOADING',
      recordStatus: 'BUFFERING'
    });
    // stop and unload ongoing recording
    try {
      await this.recording.stopAndUnloadAsync();
      this.recording.setOnRecordingStatusUpdate(null);
      this.addDebugStatement(' +++ unloading recording before playing +++');
      this.setState({
        playStatus: 'STOPPED',
        recordStatus: 'RECORDING_COMPLETE'
      });
    } catch (error) {
      this.addDebugStatement(`Error: stopAndUnloadAsync ${error}`);
      this.setState({
        recordStatus: 'ERROR'
      });
    }

    // get the file info
    let info;
    try {
      info = await FileSystem.getInfoAsync(this.recording.getURI());
    } catch (error) {
      this.addDebugStatement(`Error: FileSystem.getInfoAsync ${error}`);
      this.setState({
        recordStatus: 'ERROR'
      });
    }

    this.addDebugStatement(`FILE INFO: ${JSON.stringify(info)}`);

    try {
      await Audio.setAudioModeAsync(this.props.audioMode);
      this.setState({
        recordStatus: 'RECORDING_COMPLETE'
      });
    } catch (error) {
      this.addDebugStatement(`Error: Audio.setAudioModeAsync ${error}`);
      this.setState({
        recordStatus: 'ERROR'
      });
    }

    // now that recording is complete, create and load a new sound object
    // to save to component state so that it can be played back later
    try {
      const { sound, status } = await this.recording.createNewLoadedSoundAsync(
        null,
        this.onPlaybackStatusUpdate
      );
      this.setState({
        soundFileInfo: { ...info, durationMillis: status.durationMillis }
      });

      this.setState({
        positionMillis: status.positionMillis,
        durationMillis: status.durationMillis,
        maxSliderValue: status.durationMillis,
        currentSliderValue: 0
      });
      this.sound = sound;
    } catch (error) {
      this.addDebugStatement(`Error: createNewLoadedSound ${error}`);
    }
    this.setState({
      playStatus: 'STOPPED',
      recordStatus: 'RECORDING_COMPLETE'
    });
  }
/*
  Stop recording, enable playback, and write sound file information to redux store
   */
Stop recording, enable playback, and write sound file information to redux store
Stop recording enable playback and write sound file information to redux store
async stopRecordingAndEnablePlayback() {
    this.setState({
      playStatus: 'LOADING',
      recordStatus: 'BUFFERING'
    });
    try {
      await this.recording.stopAndUnloadAsync();
      this.recording.setOnRecordingStatusUpdate(null);
      this.addDebugStatement(' +++ unloading recording before playing +++');
      this.setState({
        playStatus: 'STOPPED',
        recordStatus: 'RECORDING_COMPLETE'
      });
    } catch (error) {
      this.addDebugStatement(`Error: stopAndUnloadAsync ${error}`);
      this.setState({
        recordStatus: 'ERROR'
      });
    }
    let info;
    try {
      info = await FileSystem.getInfoAsync(this.recording.getURI());
    } catch (error) {
      this.addDebugStatement(`Error: FileSystem.getInfoAsync ${error}`);
      this.setState({
        recordStatus: 'ERROR'
      });
    }
    this.addDebugStatement(`FILE INFO: ${JSON.stringify(info)}`);
    try {
      await Audio.setAudioModeAsync(this.props.audioMode);
      this.setState({
        recordStatus: 'RECORDING_COMPLETE'
      });
    } catch (error) {
      this.addDebugStatement(`Error: Audio.setAudioModeAsync ${error}`);
      this.setState({
        recordStatus: 'ERROR'
      });
    }
    try {
      const { sound, status } = await this.recording.createNewLoadedSoundAsync(
        null,
        this.onPlaybackStatusUpdate
      );
      this.setState({
        soundFileInfo: { ...info, durationMillis: status.durationMillis }
      });
      this.setState({
        positionMillis: status.positionMillis,
        durationMillis: status.durationMillis,
        maxSliderValue: status.durationMillis,
        currentSliderValue: 0
      });
      this.sound = sound;
    } catch (error) {
      this.addDebugStatement(`Error: createNewLoadedSound ${error}`);
    }
    this.setState({
      playStatus: 'STOPPED',
      recordStatus: 'RECORDING_COMPLETE'
    });
  }
async stopRecordingAndEnablePlayback ( ) { this . setState ( { playStatus : 'LOADING' , recordStatus : 'BUFFERING' } ) ; try { await this . recording . stopAndUnloadAsync ( ) ; this . recording . setOnRecordingStatusUpdate ( null ) ; this . addDebugStatement ( ' +++ unloading recording before playing +++' ) ; this . setState ( { playStatus : 'STOPPED' , recordStatus : 'RECORDING_COMPLETE' } ) ; } catch ( error ) { this . addDebugStatement ( ` ${ error } ` ) ; this . setState ( { recordStatus : 'ERROR' } ) ; } let info ; try { info = await FileSystem . getInfoAsync ( this . recording . getURI ( ) ) ; } catch ( error ) { this . addDebugStatement ( ` ${ error } ` ) ; this . setState ( { recordStatus : 'ERROR' } ) ; } this . addDebugStatement ( ` ${ JSON . stringify ( info ) } ` ) ; try { await Audio . setAudioModeAsync ( this . props . audioMode ) ; this . setState ( { recordStatus : 'RECORDING_COMPLETE' } ) ; } catch ( error ) { this . addDebugStatement ( ` ${ error } ` ) ; this . setState ( { recordStatus : 'ERROR' } ) ; } try { const { sound , status } = await this . recording . createNewLoadedSoundAsync ( null , this . onPlaybackStatusUpdate ) ; this . setState ( { soundFileInfo : { ... info , durationMillis : status . durationMillis } } ) ; this . setState ( { positionMillis : status . positionMillis , durationMillis : status . durationMillis , maxSliderValue : status . durationMillis , currentSliderValue : 0 } ) ; this . sound = sound ; } catch ( error ) { this . addDebugStatement ( ` ${ error } ` ) ; } this . setState ( { playStatus : 'STOPPED' , recordStatus : 'RECORDING_COMPLETE' } ) ; }
Stop recording, enable playback, and write sound file information to redux store
Stop recording enable playback and write sound file information to redux store
// stop and unload ongoing recording // get the file info // now that recording is complete, create and load a new sound object // to save to component state so that it can be played back later