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();
        await recording.prepareToRecordAsync(Audio.RECORDING_OPTIONS_PRESET_HIGH_QUALITY);
        await recording.startAsync();
        const audio_stream = recording.getURI();
        await recording.stopAndUnloadAsync();
    return (
            <Button title="Start recording" onPress={() => start()} />

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.

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