Browse SDKs · React Native
Platform
SDKsReact Native

Create audio message from URL

Construct an audio message using pre-uploaded remote audio metadata and URL using the OpenIM React Native SDK.

Copy

Construct an audio message using remote metadata from a pre-uploaded audio resource:

const message = await OpenIMSDK.createSoundMessageByURL({
  uuid: 'audio-001',
  soundPath: '',
  sourceUrl: 'https://www.example.com/sound.mp3',
  dataSize: 54000,
  duration: 18,
  soundType: 'audio/mpeg',
});

Parameters

ParameterTypeRequiredDescription
uuidstringYesUnique resource identifier for the audio file.
soundPathstringYesLocal audio file path; pass empty string "" when using remote-only assets.
sourceUrlstringYesAccessible remote URL where the audio file is hosted.
dataSizenumberYesAudio file size in bytes.
durationnumberYesAudio duration in seconds.
soundTypestringNoAudio MIME type (e.g. 'audio/mpeg').

Return value

A resolved Promise returns the initialized MessageItem object with remote audio properties stored in soundElem.

This method builds the message structure strictly in client memory; it does not dispatch messages to the server or trigger lifecycle events. After initialization, invoke Send uploaded media message to deliver it to a conversation without repeating file uploads.