-
-
Notifications
You must be signed in to change notification settings - Fork 44
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
I tried to record audio using the steps in the documentation, but the app crashed.
Assertion failed: (isString()), function getString, file jsi.h, line 1561.
Steps to reproduce
- Install react-native-audio-api
- Configure expo plugins:
{
"plugins": [
[
"react-native-audio-api",
{
"iosBackgroundMode": true,
"iosMicrophonePermission": "This app requires access to the microphone to record audio.",
"androidPermissions" : [
"android.permission.RECORD_AUDIO",
"android.permission.FOREGROUND_SERVICE",
"android.permission.FOREGROUND_SERVICE_MICROPHONE",
],
"androidForegroundService": true,
"androidFSTypes": ["microphone"]
}
]
]
}- Create a demo page:
import React, { useState } from 'react';
import { View, Pressable, Text } from 'react-native';
import { AudioRecorder, AudioManager } from 'react-native-audio-api';
AudioManager.setAudioSessionOptions({
iosCategory: 'record',
iosMode: 'default',
iosOptions: [],
});
const audioRecorder = new AudioRecorder();
// Enables recording to file with default configuration
audioRecorder.enableFileOutput();
const MyRecorder: React.FC = () => {
const [isRecording, setIsRecording] = useState(false);
const onStart = async () => {
if (isRecording) {
return;
}
// Make sure the permissions are granted
const permissions = await AudioManager.requestRecordingPermissions();
if (permissions !== 'Granted') {
console.warn('Permissions are not granted');
return;
}
// Activate audio session
const success = await AudioManager.setAudioSessionActivity(true);
if (!success) {
console.warn('Could not activate the audio session');
return;
}
const result = audioRecorder.start();
if (result.status === 'error') {
console.warn(result.message);
return;
}
console.log('Recording started to file:', result.path);
setIsRecording(true);
};
const onStop = () => {
if (!isRecording) {
return;
}
const result = audioRecorder.stop();
console.log(result);
setIsRecording(false);
AudioManager.setAudioSessionActivity(false);
};
return (
<View>
<Pressable onPress={isRecording ? onStop : onStart}>
<Text>{isRecording ? 'Stop' : 'Record'}</Text>
</Pressable>
</View>
);
};
export default MyRecorder;- Click
Record
Snack or a link to a repository
https://docs.swmansion.com/react-native-audio-api/docs/inputs/audio-recorder
React Native Audio API version
0.11.2
React Native version
0.81.5
Platforms
iOS
JavaScript runtime
None
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working