Audio.prepareToRecordAsync failed - cannot-read-property-uri-of-undefined

  1. SDK Version: 37
  2. Platforms(Android/iOS/web/all): all

I’m trying to start a new recording in Expo react native but for some odd reason the app crashes. The code i written is pretty much copy paste from the official expo docs.

import React, { useState, useEffect } from 'react';
import { Audio } from 'expo-av';
import PitchFinder from "pitchfinder";
import { StyleSheet, Text, View, Button } from 'react-native';

const Tuner = () => {
    const pitchFinder = new PitchFinder.YIN();
    const start = async () => {
        const recording = new Audio.Recording();
        console.log(recording)
        await recording.prepareToRecordAsync(Audio.RECORDING_OPTIONS_PRESET_HIGH_QUALITY);
        await recording.startAsync();
        const audio_stream = recording.getURI();
        console.log(audio_stream);
        await recording.stopAndUnloadAsync();
    }
    return (
        <View>
            <Button title="Start recording" onPress={() => start()} />
        </View>
    )
};

export default Tuner;

The app crashes at

await recording.prepareToRecordAsync(Audio.RECORDING_OPTIONS_PRESET_HIGH_QUALITY);

with the error: Unhandled Rejection (TypeError): Cannot read property ‘uri’ of undefined

I have this same exact issue.

Same issue, any updates?

It’s a bug I guess. https://github.com/expo/expo/issues/8447

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.