浏览 SDKs · HarmonyOS
平台
SDKsHarmonyOS商业版

使用 URL 创建音频消息

根据已经上传的音频资源信息创建待发送消息。

复制
import sdk, { CreateSoundMessageByURLReq, CreateSoundMessageResp } from '@openimsdk/imsdk';

const request: CreateSoundMessageByURLReq = {
  uuid: uploaded.uuid,
  soundPath: '',
  sourceURL: uploaded.url,
  dataSize: uploaded.size,
  duration: 12,
  soundType: 'audio/mp4',
};
const response: CreateSoundMessageResp = await sdk.createSoundMessageByURL(request);
const message = response.message;

所有字段均为必填。dataSize 使用字节,duration 使用秒,soundType 填写真实 MIME 类型。不要使用即将过期且接收端无法访问的临时 URL。