以Promise风格调用: 支持
保存视频到系统相册。支持mp4视频格式。
属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| filePath | string | 是 | 视频文件路径,可以是临时文件路径也可以是永久文件路径 (本地路径) | |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
|---|---|---|
| errMsg | string |
function saveVideoToPhotosAlbum(filePath) {
return new Promise((resolve, reject) => {
xhs.saveVideoToPhotosAlbum({
filePath, // 视频文件路径
success: (res) => resolve(res),
fail: (err) => reject(err),
});
});
}
// 调用示例
const videoPath = '/path/to/video.mp4'; // 替换为实际的视频文件路径
saveVideoToPhotosAlbum(videoPath)
.then((res) => {
console.log('视频保存成功:', res.errMsg);
})
.catch((err) => {
console.error('视频保存失败:', err);
});