---
name: "startDownloadMessageVideoForComposition"
mode: "kit"
versionRequirements:
  - { name: "IPCKit", version: "6.3.1" }
  - { name: "@ray-js/ray", version: "1.7.30" }
platform:
  - "iOS"
  - "Android"
async: true
title: "startDownloadMessageVideoForComposition - 将IPC云端视频下载到 APP 本地"
---

## startDownloadMessageVideoForComposition

> [VERSION] IPCKit >= 6.3.1 | @ray-js/ray >= 1.7.30

> [PLATFORM] iOS, Android

> ⚡ **支持 Promise 调用** — 不传 success / fail / complete 回调时，该方法返回 Promise。

### 描述

视频下载，如果有多个视频文件，会合成为一个视频文件

### 参数

| 属性 | 类型 | 必填 | 默认值 | 最低版本 | 描述 |
| --- | --- | --- | --- | --- | --- |
| `deviceId` | `string` | 是 | - | `6.3.1` | 设备 ID |
| `fileInfo` | `string` | 是 | - | `6.3.1` | 文件信息，json字符串  {"fileInfo":[   { 	    "fileUrl": "xxx1",    "key": "media key 1"  },  {    "fileUrl": "xxx2", 	    "key": "media key 2"  }, 	  {    "fileUrl": "xxx3",    "key": "media key 3"  }] } |
| `savePath` | `number` | 是 | - | `6.3.1` | 保存路径   0: 默认值，保存在手机相册。1: 保存在 App 相册。2: 同时保存到手机相册和 App 相册 |
| `option` | `MediaProcessOptionModel` | 否 | - | `6.3.1` | 视频处理的的配置选项 |
| `complete` | `() => void` | 否 | - | - | 接口调用结束的回调函数（调用成功、失败都会执行） |
| `success` | `(params: Object) => void` ↓见下方 | 否 | - | - | 接口调用成功的回调函数 |
| `fail` | `(params: Object) => void` ↓见下方 | 否 | - | - | 接口调用失败的回调函数 |

#### success 回调参数

| 属性 | 类型 | 最低版本 | 描述 |
| --- | --- | --- | --- |
| `path` | `string` | `6.3.1` | 云存下载完成后保存路径 |
| `thingfilePath` | `string` | `6.7.1` | file thingfilePath |

#### fail 回调参数

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `errorMsg` | `string` | 错误信息 |
| `errorCode` | `string \| number` | 错误码 |
| `innerError` | `Object` | 错误扩展 |

##### fail(params).innerError 的属性

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `errorCode` | `string \| number` | 错误扩展码 |
| `errorMsg` | `string` | 错误扩展信息 |


### 引用对象

##### `interface` MediaProcessOptionModel

| 属性 | 类型 | 最低版本 | 描述 |
| --- | --- | --- | --- |
| `targetWidth` | `number` | `6.3.1` | 目标视频宽 |
| `targetHeight` | `number` | `6.3.1` | 目标视频高 |
| `useFirstVideoResolution` | `boolean` | `6.3.1` | 第一个视频的分辨率为主 默认值为true |
| `rotation` | `number` | `6.3.1` | 旋转角度 仅支持：0(正常模式，不旋转)、1(顺时针旋转90度)、2(顺时针旋转180度)、3(顺时针旋转270度 |


### 示例代码

#### Demo

```tsx
import { ipc } from '@ray-js/ray'

ipc.startDownloadMessageVideoForComposition({
  deviceId: "xx",
  fileInfo: "xx",
  savePath: 1,
  option: {},
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});
```
