Browse SDKs · React Native
SDKsReact Native

Create an audio message from a URL

OpenIM React Native SDK guide for create an audio message from a url.

Copy

Use createSoundMessageByURL() to create a message from uploaded audio resource information.

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
uuidstringYesAudio resource ID.
soundPathstringYesLocal audio path. Pass an empty string when only a remote resource is available.
sourceUrlstringYesURL of the uploaded audio.
dataSizenumberYesAudio size in bytes.
durationnumberYesAudio duration in seconds.
soundTypestringNoAudio type.

The call returns a MessageItem ready to send. Use the actual upload result for resource information, then use Send an uploaded media message.