SDKsAndroid
Create an audio message from a local path
Create an audio message from an absolute path.
Construct a voice or audio message object from an absolute filesystem path recorded on the local device. When sending via Send a message, the SDK automatically uploads the file and tracks progress.
Code example
String absolutePath = "/storage/emulated/0/Recordings/voice_sample.m4a";
long durationSeconds = 8L; // Duration: 8 seconds
Message message = OpenIMClient.getInstance().messageManager.createSoundMessageFromFullPath(
absolutePath,
durationSeconds
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
soundPath | String | Yes | Absolute filesystem path of the audio file on the local device. Ensure read permissions are granted. |
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 upload and deliver the audio message.
Was this page helpful?