Browse SDKs · Flutter
Platform
SDKsFlutter

Create an audio message

Create an audio message from a platform path with the OpenIM Flutter SDK.

Copy

Construct an audio/voice message object from a local filesystem audio path:

Parameters

ParameterTypeRequiredDescription
soundPathStringYesLocal filesystem path to the audio file on the current device.
durationintYesAudio playback duration in seconds.

Code example

final message = await OpenIM.iMManager.messageManager.createSoundMessage(
  soundPath: soundPath,
  duration: durationSeconds,
);

The specified path must be an accessible file with read permissions on the current device, 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 an absolute filesystem path, see Create an audio message from full path; if the audio is already hosted on object storage, see Create an audio message by URL.