mediasfu-reactnative
Version:
MediaSFU Prebuilt React Native SDK
39 lines • 1.46 kB
JavaScript
/**
* Displays an alert message when the recording has stopped, indicating the reason.
*
* @param {StoppedRecordingOptions} options - Options for showing the recording stopped alert.
* @param {string} options.state - The state of the recording, should be "stop" to trigger the alert.
* @param {string} options.reason - Reason why the recording stopped.
* @param {ShowAlert} [options.showAlert] - Optional function to display the alert message.
*
* @returns {Promise<void>} A promise that resolves once the alert is shown, if applicable.
*
* @example
* ```typescript
* const options = {
* state: "stop",
* reason: "The session ended.",
* showAlert: (alert) => console.log(alert.message),
* };
*
* stoppedRecording(options);
* // Output: "The recording has stopped - The session ended."
* ```
*/
export const stoppedRecording = async ({ state, reason, showAlert, }) => {
try {
// Ensure the state is 'stop' before showing the alert
if (state === 'stop') {
showAlert === null || showAlert === void 0 ? void 0 : showAlert({
message: `The recording has stopped - ${reason}.`,
duration: 3000,
type: 'danger',
});
}
}
catch (error) {
console.log('Error in stoppedRecording: ', error);
// throw new Error("Failed to display the recording stopped alert message.");
}
};
//# sourceMappingURL=stoppedRecording.js.map