小程序
小游戏
企业微信
微信支付
扫描小程序码分享
ChooseMessageFile 安卓无法选择上传音频文件如:mp3、wav,但是iOS可以
2 个回答
本回答由AI生成,可能已过期、失效或不适用于当前情形,请谨慎参考
加粗
标红
插入代码
插入链接
插入图片
上传视频
chooseAudioAndSubtitleFiles(this: any) {
const that = this;
wx.chooseMessageFile({
count: this.data.maxCount - this.data.audioList.length,
type: 'all',
extension: ['mp3', 'wav', 'aac', 'm4a', 'flac', 'aiff', 'ogg'],
success(res: any) {
that.handleSelectedFiles(res.tempFiles);
},
});
/**
* 处理选中的文件
*/
handleSelectedFiles(this: any, audioFiles: any[]) {
// 创建音频条目(标记为上传中)
const newAudioItems = audioFiles.map((file: any, index: number) => {
const item = that.createAudioItem(file);
item.order = that.data.audioList.length + index + 1; // 修正order自增
item.is_new = 1; // 标记为新增
item.is_delete = 0; // 未删除
if (item.audioFile) {
item.audioFile.uploading = true; // 标记为上传中
}
return item;
let updatedList = [...that.data.audioList, ...newAudioItems];
that.setData({ audioList: updatedList });
// 开始上传音频文件
audioFiles.forEach((file: any, index: number) => {
that.uploadAudioFile(file, newAudioItems[index].id);
// 字幕上传功能已禁用,不再匹配和上传字幕
},改成all图片tab有数据,但是文件tab没有数据,确定聊天中是有响应的文件的
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
chooseAudioAndSubtitleFiles(this: any) {
const that = this;
wx.chooseMessageFile({
count: this.data.maxCount - this.data.audioList.length,
type: 'all',
extension: ['mp3', 'wav', 'aac', 'm4a', 'flac', 'aiff', 'ogg'],
success(res: any) {
that.handleSelectedFiles(res.tempFiles);
},
});
},
/**
* 处理选中的文件
*/
handleSelectedFiles(this: any, audioFiles: any[]) {
const that = this;
// 创建音频条目(标记为上传中)
const newAudioItems = audioFiles.map((file: any, index: number) => {
const item = that.createAudioItem(file);
item.order = that.data.audioList.length + index + 1; // 修正order自增
item.is_new = 1; // 标记为新增
item.is_delete = 0; // 未删除
if (item.audioFile) {
item.audioFile.uploading = true; // 标记为上传中
}
return item;
});
let updatedList = [...that.data.audioList, ...newAudioItems];
that.setData({ audioList: updatedList });
// 开始上传音频文件
audioFiles.forEach((file: any, index: number) => {
that.uploadAudioFile(file, newAudioItems[index].id);
});
// 字幕上传功能已禁用,不再匹配和上传字幕
},改成all图片tab有数据,但是文件tab没有数据,确定聊天中是有响应的文件的