Create an audio message from a local path
Create an audio message from an absolute path with the OpenIM Flutter SDK.
Construct an audio/voice message object from an absolute filesystem path on the local device:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
soundPath | String | Yes | Absolute filesystem path to the audio file on the current device. |
duration | int | Yes | Audio playback duration in seconds. |
Code example
final message = await OpenIM.iMManager.messageManager
.createSoundMessageFromFullPath(
soundPath: absolutePath,
duration: durationSeconds,
);The absolute path must exist and have read permissions on the current platform, and duration is measured in seconds.
Return value
Returns a Future resolving to an audio Message object ready for transmission. Its audio properties are 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, does not upload files, and does not trigger new-message event callbacks. Once constructed, pass the returned Message instance to Send a message, which handles media upload and message delivery. To create an audio message from a relative platform path, see Create an audio message; if the audio is already hosted on object storage, see Create an audio message by URL.
Was this page helpful?