SDKsAndroid
Create an audio message
Create an audio message from a path relative to the SDK data directory.
Construct a voice or audio message object from a relative path within the SDK initialization data directory. When sending via Send a message, the SDK automatically uploads the audio file.
Code example
String soundPath = "sounds/voice_001.m4a";
long durationSeconds = 12L; // Duration: 12 seconds
Message message = OpenIMClient.getInstance().messageManager.createSoundMessage(
soundPath,
durationSeconds
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
soundPath | String | Yes | Audio file path relative to the SDK initialization data directory. |
duration | long | Yes | Audio playback duration in seconds. |
Return value
Returns the created Message object with contentType set to MessageType.VOICE.
State changes after the call
- Local initialization: Initializes the local
Messagestructure without starting network uploads. - Transmission: Call Send a message to deliver the audio message. For absolute local filesystem paths, see Create an audio message from a local path.
Was this page helpful?