SDKsReact Native
Create audio message from URL
Construct an audio message using pre-uploaded remote audio metadata and URL using the OpenIM React Native SDK.
Construct an audio message using remote metadata from a pre-uploaded audio resource:
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 | Unique resource identifier for the audio file. |
soundPath | string | Yes | Local audio file path; pass empty string "" when using remote-only assets. |
sourceUrl | string | Yes | Accessible remote URL where the audio file is hosted. |
dataSize | number | Yes | Audio file size in bytes. |
duration | number | Yes | Audio duration in seconds. |
soundType | string | No | Audio MIME type (e.g. 'audio/mpeg'). |
Return value
A resolved Promise returns the initialized MessageItem object with remote audio properties stored in soundElem.
This method builds the message structure strictly in client memory; it does not dispatch messages to the server or trigger lifecycle events. After initialization, invoke Send uploaded media message to deliver it to a conversation without repeating file uploads.
Was this page helpful?