SDKsWASM
Create an audio message from a URL
Create an audio message from an uploaded resource URL with the WASM SDK.
createSoundMessageByURL() creates a message from information for an audio resource that has already been uploaded.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
uuid | string | Yes | Unique identifier for the audio resource. |
soundPath | string | Yes | Local filename or application-defined path of the audio file. Pass an empty string when only a remote resource is available. |
sourceUrl | string | Yes | Accessible URL of the uploaded audio. |
dataSize | number | Yes | Audio size in bytes. |
duration | number | Yes | Audio duration. |
soundType | string | No | Audio MIME type. |
const { data: message } = await openimsdk.createSoundMessageByURL({
uuid: crypto.randomUUID(),
soundPath: '',
sourceUrl: uploaded.url,
dataSize: uploaded.size,
duration,
soundType: uploaded.contentType,
});Use the byte count for dataSize and the duration value expected by the SDK for duration. The URL, type, and size must come from the actual upload result. When the Promise resolves, it has created only a pending message object; send it with sendMessageNotOss().
Was this page helpful?