Audio
语音消息.
Audio 分为 OnlineAudio 与 OfflineAudio. 在本地上传的, 或手动构造的语音为 OfflineAudio. 从服务器接收的语音为 OnlineAudio.
上传和发送语音
使用 AudioSupported.uploadAudio 上传语音到服务器并取得 Audio 消息实例, 然后通过 Contact.sendMessage 发送.
Java 示例:
Audio audio;
try {
audio = group.uploadAudio(resource); // 上传文件得到语音实例
} finally {
resource.close(); // 保证资源正常关闭
}
group.sendMessage(audio); // 发送语音消息
Content copied to clipboard
下载语音
使用 OnlineAudio.urlForDownload 获取文件下载链接.
Audio 与 Voice 的转换
原 Voice 已弃用故不推荐进行兼容转换. Audio 将有稳定性保证, 请尽量使用新的 Audio.
将 Audio 转为 Voice: Voice.fromAudio 将 Voice 转为 Audio: Voice.toAudio
Since
2.7
Types
Key
Link copied to clipboard
Functions
contentEquals
Link copied to clipboard
open fun contentEquals(another: String, ignoreCase: Boolean = false): Boolean
Content copied to clipboard
判断内容是否与 another 相等.
open fun contentEquals(another: Message, ignoreCase: Boolean = false): Boolean
Content copied to clipboard
判断内容是否与 another 相等即 this
与 another 的 contentToString 相等.
open fun contentEquals(another: Message, ignoreCase: Boolean = false, strict: Boolean = false): Boolean
Content copied to clipboard
判断内容是否与 another 相等即 this
与 another 的 contentToString 相等. strict 为 true
时, 还会额外判断每个消息元素的类型, 顺序和属性. 如 Image 会判断 Image.imageId
contentToString
Link copied to clipboard
转为最接近官方格式的字符串. 如 At(member) + "test"
将转为 "@群名片 test"
.
followedBy
Link copied to clipboard
将 this
和 tail 连接.
Properties
codec
Link copied to clipboard
filename
Link copied to clipboard
文件名称. 通常为 XXX.amr
. 服务器要求文件名后缀必须为 ".amr", 但其编码方式也有可能是非 AudioCodec.AMR.