Create an audio message from a URL
Create an audio message from an uploaded audio element with the OpenIM Flutter SDK.
Construct an audio/voice message object using audio metadata and a URL already uploaded to external object storage:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
soundElem | SoundElem | Yes | Audio metadata model containing the verified download URL, UUID, file byte size, and duration in seconds. |
Code example
final message = await OpenIM.iMManager.messageManager
.createSoundMessageByURL(soundElem: soundElem);The URL, duration, and file size in SoundElem must reflect actual media upload results to enable recipients to buffer and render playback bars accurately.
Return value
Returns a Future resolving to an audio Message object ready for transmission. Its audio payload is stored in soundElem.
State changes after the call
Creating a message only constructs the local message data structure in memory; it does not perform network transmission and does not trigger new-message event callbacks. Because the audio file has already been uploaded, pass the returned Message instance to Send a message without OSS to deliver it without duplicate uploads. If you need the SDK to upload local audio files automatically, see Create an audio message.
Was this page helpful?