RecorderManager.onError
Register a listener function that listens to recording error events.
Parameters
Type | Required | Description |
Yes | The function that listens to recording error events. When an error occurs, the specified listener function is triggered. |
Function listener
The following table lists the properties of Function listener:
Property | Type | Required | Description |
error | Number | Yes | The error code. For details, see Error codes. |
errorMessage | String | Yes | The error message. For details, see Error codes. |
Error codes
Error code | Error message | Further action |
2 | Invalid parameter | Check parameter values and ensure that the values are configured as valid types. |
3 | Unknown error | Check whether the input parameters are valid. Invalid parameters will result in encoding failures.
|
4 (Android) | Recording is already underway | Consider addressing this scenario in the interaction design. |
8607 (iOS) | Recording is already underway | Consider addressing this scenario in the interaction design. |
7 | Recording duration is not enough | Ensure that the recording duration exceeds 1 second. Consider addressing this scenario in the interaction design. |
10 | Not grant permission for audio record | This is usually caused by not granting microphone permissions. You can call my.showAuthGuide to guide the user to grant the relevant system permissions. |
2001 | User denied the authorization. | The user refused to grant permissions to the mini-program. Consider addressing this scenario in the interaction design. If necessary, explain the necessity of the authorization to the user. |
2002 | Authorization denied. | This error occurs when the authorization interface is called again after the user denied authorization to the mini-program and selected Always keep the above choice. If necessary, you can guide the user to grant permissions via manual settings: Find the upper-right capsule button in the mini program > Click Settings > Turn on the permission switch. You can also open the settings page by calling my.openSetting. |
2003 | User denied the authorization and selected Always keep the above choice. | The user denied authorization to the mini program and selected Always keep the above choice. If necessary, you can guide the user to grant permissions via manual settings: Find the upper-right capsule button in the mini program > Click Settings > Turn on the permission switch. You can also open the settings page by calling my.openSetting. |
Sample code
const recorderManager = my.getRecorderManager();
recorderManager.onError(res => {
console.log (res);
});