Skip to content

Commit ace6f02

Browse files
committed
fix(example): recording expo-av
1 parent 6f3a39c commit ace6f02

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

example/App.tsx

+31-22
Original file line numberDiff line numberDiff line change
@@ -1189,29 +1189,38 @@ function RecordUsingExpoAvDemo() {
11891189

11901190
const handleStart = async () => {
11911191
setIsRecording(true);
1192+
try {
1193+
await Audio.setAudioModeAsync({
1194+
allowsRecordingIOS: true,
1195+
playsInSilentModeIOS: true,
1196+
});
1197+
const { recording } = await Audio.Recording.createAsync({
1198+
isMeteringEnabled: true,
1199+
android: {
1200+
bitRate: 32000,
1201+
extension: ".m4a",
1202+
outputFormat: AndroidOutputFormat.MPEG_4,
1203+
audioEncoder: AndroidAudioEncoder.AAC,
1204+
numberOfChannels: 1,
1205+
sampleRate: 16000,
1206+
},
1207+
ios: {
1208+
...Audio.RecordingOptionsPresets.HIGH_QUALITY.ios,
1209+
numberOfChannels: 1,
1210+
bitRate: 16000,
1211+
extension: ".wav",
1212+
outputFormat: IOSOutputFormat.LINEARPCM,
1213+
},
1214+
web: {
1215+
mimeType: "audio/wav",
1216+
bitsPerSecond: 128000,
1217+
},
1218+
});
11921219

1193-
const { recording } = await Audio.Recording.createAsync({
1194-
isMeteringEnabled: true,
1195-
android: {
1196-
bitRate: 32000,
1197-
extension: ".m4a",
1198-
outputFormat: AndroidOutputFormat.MPEG_4,
1199-
audioEncoder: AndroidAudioEncoder.AAC,
1200-
numberOfChannels: 1,
1201-
sampleRate: 16000,
1202-
},
1203-
ios: {
1204-
...Audio.RecordingOptionsPresets.HIGH_QUALITY.ios,
1205-
extension: ".wav",
1206-
outputFormat: IOSOutputFormat.LINEARPCM,
1207-
},
1208-
web: {
1209-
mimeType: "audio/wav",
1210-
bitsPerSecond: 128000,
1211-
},
1212-
});
1213-
1214-
recordingRef.current = recording;
1220+
recordingRef.current = recording;
1221+
} catch (e) {
1222+
console.log("Error starting recording", e);
1223+
}
12151224
};
12161225

12171226
const handleStop = async () => {

0 commit comments

Comments
 (0)