我正试图在世博会上开始一段新的录音,但由于一些奇怪的原因,这个应用程序崩溃了。我编写的代码基本上是复制粘贴从官方博览会文档。
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;该应用程序在await recording.prepareToRecordAsync(Audio.RECORDING_OPTIONS_PRESET_HIGH_QUALITY);上崩溃时出现错误
未处理拒绝(TypeError):无法读取未定义
的属性'uri‘
发布于 2020-04-10 15:41:17
请再次检查世博会文件,检查许可
https://docs.expo.io/versions/latest/sdk/audio/
试着
const recording = new Audio.Recording();
try {
await recording.prepareToRecordAsync(Audio.RECORDING_OPTIONS_PRESET_HIGH_QUALITY);
await recording.startAsync();
// You are now recording!
} catch (error) {
// An error occurred!
}https://stackoverflow.com/questions/61143575
复制相似问题