---
name: "IpcPlayerContext.snapshot"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.21.8" }
title: "IpcContext.snapshot - 截图"
---

## IpcPlayerContext.snapshot

> [VERSION] Base Library >= 2.21.8

### Description

Capture snapshot

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `options` | `IpcSnapshotOption` | Yes | Snapshot options |

### Return Value

None


### Referenced Types

##### `interface` IpcSnapshotOption

| Property | Type | Description |
| --- | --- | --- |
| `saveToAlbum` | `number` | Whether to save to album: 0 for system album, 1 for IPC album |
| `success` | `(result: IpcSnapshotResult) => void` | Callback invoked on successful API call |
| `fail` | `(result: IpcFailResult) => void` | Callback on failure |
| `complete` | `() => void` | Callback on complete (success or failure) |

##### `interface` IpcSnapshotResult

| Property | Type | Description |
| --- | --- | --- |
| `path` | `string` | Screenshot file path |

##### `interface` IpcFailResult

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string` | Error code |
| `errorMsg` | `string` | Error message |


### Examples

#### Capture a snapshot and save to the album

```ts
const ipcCtx = ty.createIpcPlayerContext('deviceId');
ipcCtx.snapshot({
  saveToAlbum: 1,
  success(res) {
    console.log('Snapshot successful', res.path);
  },
});
```
