uni-app uni.chooseVideo 选择视频遇到 正在从iCloud同步图片后无法自动关闭选择页面

uni-app uni.chooseVideo 选择视频遇到 正在从iCloud同步图片后无法自动关闭选择页面

项目属性
产品分类 uniapp/App
PC开发环境操作系统 Mac
PC开发环境操作系统版本号 15.2 (24C101)
HBuilderX版本号 4.45
手机系统 iOS
手机系统版本号 iOS 18
手机厂商 苹果
手机机型 iphone13
页面类型 vue
vue版本 vue3
打包方式 离线
项目创建方式 CLI
CLI版本号 3.0.0-4040520250104002

示例代码:

uni.chooseVideo({
sourceType: ['album'],
compressed: false,
success: function (res) {
const src = res.tempFilePath;
if (res.size > 1024 * 1024 * 50) {
Utils.showToast('视频大小不能超过50M');
return;
}
const uuid = uuidv4();
let tempVideoDescribeItem: Wm.UploadVideoItem = {
uploadId: uuid,
material_describe: '',
id: '',
isUploading: true,
percent: 0
};
if (syncHome) {
homePageStore.showImageOrVideoStatus.isUploading = true;
}
tempUploadVideoList.value.unshift(tempVideoDescribeItem);
let isShowVideoDescribePopup = false;
Utils.uploadFile(
src,
{ purpose: 'double-slave', portrait: 'true' },
(res: UniApp.OnProgressUpdateResult) => {
console.log('上传进度', res);
if (res.progress > 99) {
updateTempUploadVideoItem({
uploadId: uuid,
percent: 99
});
if (syncHome) {
homePageStore.showImageOrVideoStatus.percent = 99;
}
} else {
updateTempUploadVideoItem({
uploadId: uuid,
percent: res.progress
});
if (syncHome) {
homePageStore.showImageOrVideoStatus.percent = res.progress;
}
}
if (!isShowVideoDescribePopup) {
isShowVideoDescribePopup = true;
inputPopupRef.value.open({
id: uuid,
value: tempVideoDescribeItem.material_describe
});
}
}
)
.then(async (res: any) => {
console.log(res);
if (res.data) {
if (syncHome) {
homePageStore.showImageOrVideoStatus.percent = 100;
homePageStore.showImageOrVideoStatus.isUploading = false;
}
Utils.showToast('上传成功');
let tempList = [];

let isExist = false;
for (let i = 0; i < selectVideoMaterialList.value.length; i++) {
const ele = selectVideoMaterialList.value[i];
if (ele.id === res.data.id) {
isExist = true;
break;
}
}
const data = getTempUploadVideoItem({ uploadId: uuid });
if (!isExist) {
if (selectVideoMaterialList.value.length < 5) {
selectVideoMaterialList.value.push({
id: res.data.id,
path: res.data.path,
url: res.data.url,
material_describe: data ? data?.material_describe : ''
});
}
}
updateTempUploadVideoItem({
uploadId: uuid,
id: res.data.id
});
await Utils.updateVideoInfo({
id: res.data.id,
path: res.data.path,
crop_area: '[[0,0],[1080,1920]]',
describe: data ? data?.material_describe : ''
});
await getVideoList();
// removeTempUploadVideoItem({ uploadId: uuid });
updateTempUploadVideoItem({
uploadId: uuid,
isUploading: false
});
handleSelect();
// Utils.saveDigitHumanStorage();
}
})
.catch((err: any) => {
console.log(err);
});
},
fail: function (err: any) {
console.log(err);
if (err.errMsg.indexOf('Permission') > -1) {
videoUtils.authAlbum({
content: '请授权相册权限,否则无法上传视频。'
});
} else {
Utils.showToast('请稍后再试');
}
}
});

操作步骤:

  • 使用iphone13调用uni.chooseVideo()选择视频两次

预期结果:

  • 希望调用uni.chooseVideo()选择视频后能关闭选择页面

实际结果:

  • 在调用uni.chooseVideo()选择视频后未能关闭选择页面,实际上success 回调已经返回了选择的视频的路径

bug描述:

  • iPhone 13 调用 chooseVideo 上传后在视频上传中再次调用,遇到 正在从ICloud同步照片 的提示后一直停留在选择视频界面没有自动返回。

附件:


更多关于uni-app uni.chooseVideo 选择视频遇到 正在从iCloud同步图片后无法自动关闭选择页面的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于uni-app uni.chooseVideo 选择视频遇到 正在从iCloud同步图片后无法自动关闭选择页面的实战教程也可以访问 https://www.itying.com/category-93-b0.html


这是一个iOS系统与uni-app交互的常见问题。当从iCloud同步照片/视频时,系统会显示同步提示,此时uni.chooseVideo的选择界面不会自动关闭。

解决方案:

  1. 在调用chooseVideo前,可以添加检查逻辑:
// 检查是否正在同步
if (uni.getSystemInfoSync().platform === 'ios') {
  // 添加同步状态检查逻辑
}
  1. 在success回调中强制关闭选择器:
success: function (res) {
  // 添加延迟确保选择器关闭
  setTimeout(() => {
    uni.hideLoading();
    // 其他处理逻辑
  }, 300);
}
  1. 对于iCloud同步问题,可以提示用户等待同步完成后再操作:
fail: function (err) {
  if (err.errMsg.includes('iCloud')) {
    uni.showToast({
      title: '请等待iCloud同步完成',
      icon: 'none'
    });
  }
}
回到顶部