Browse SDKs · uni-app / uni-app x
SDKsuni-app

Create an audio message from a URL

OpenIM uni-app / uni-app x SDK guide for Create an audio message from a URL.

Copy

createSoundMessageByURL() creates a message from already uploaded audio metadata.

Parameters

ParameterTypeDescription
uuidstring or nullUnique audio resource ID.
soundPathstring or nullLocal name or business path; use an empty string for a remote-only resource.
sourceUrlstring or nullAccessible uploaded audio URL.
dataSizenumber or nullAudio size in bytes.
durationnumber or nullDuration in the unit defined by the server protocol.
import { createSoundMessageByURL } from '@/uni_modules/unix-openim-sdk'

const message = await createSoundMessageByURL({
  uuid: createBusinessUUID(),
  soundPath: '',
  sourceUrl: uploaded.url,
  dataSize: uploaded.size,
  duration,
})

Use upload-result URL, UUID, size, and duration values. The remote resource must be accessible to recipients; a sandbox path is not a media URL. OpenIMSoundElem does not contain the Wasm soundType field. The Promise only creates a message; send it with sendMessageNotOss().