SDKsReact Native
Create an audio message from a URL
OpenIM React Native SDK guide for create an audio message from a url.
Use createSoundMessageByURL() to create a message from uploaded audio resource information.
const message = await OpenIMSDK.createSoundMessageByURL({
uuid: 'audio-001',
soundPath: '',
sourceUrl: 'https://www.example.com/sound.mp3',
dataSize: 54000,
duration: 18,
soundType: 'audio/mpeg',
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
uuid | string | Yes | Audio resource ID. |
soundPath | string | Yes | Local audio path. Pass an empty string when only a remote resource is available. |
sourceUrl | string | Yes | URL of the uploaded audio. |
dataSize | number | Yes | Audio size in bytes. |
duration | number | Yes | Audio duration in seconds. |
soundType | string | No | Audio type. |
The call returns a MessageItem ready to send. Use the actual upload result for resource information, then use Send an uploaded media message.
Was this page helpful?