# 演示模式

- Human documentation: [https://docs.univer.ai/zh-CN/guides/slides/features/core/presentation-mode](https://docs.univer.ai/zh-CN/guides/slides/features/core/presentation-mode)

- Agent Markdown: [https://docs.univer.ai/zh-CN/guides/slides/features/core/presentation-mode.md](https://docs.univer.ai/zh-CN/guides/slides/features/core/presentation-mode.md)

- Requested language: `zh-CN`

- Content language: `zh-CN`

- Documentation version: `1.0.0-rc.0`

- Source: [slides/features/core/presentation-mode.zh-CN.mdx](https://github.com/dream-num/documentation/blob/dev/content/guides/slides/features/core/presentation-mode.zh-CN.mdx)

---

`UniverSlidesUIPlugin` 会为当前演示文稿注册播放能力。播放按幻灯片顺序进行，跳过标记为跳过的页面，并在每次移动时应用解析后的切换效果。

## 开始播放

```ts
const presentation = univerAPI.getActivePresentation()

if (presentation) {
  await univerAPI.executeCommand('slide.operation.presentation.start', {
    unitId: presentation.getId(),
    fromBeginning: true,
  })
}
```

设置 `fromBeginning: false` 可从当前幻灯片开始；传入 `startSlideId` 可指定一张可见幻灯片。

## 导航与停止

```ts
await univerAPI.executeCommand('slide.operation.presentation.next')
await univerAPI.executeCommand('slide.operation.presentation.previous')

await univerAPI.executeCommand('slide.operation.presentation.go-to-slide', {
  slideId: 'summary-slide',
})

await univerAPI.executeCommand('slide.operation.presentation.stop')
```

到达最后一张可见幻灯片后再次执行下一页会停止播放；在第一页执行上一页会返回 `false`。

## 浏览器行为

全屏和双屏演示依赖浏览器 API。请直接在用户手势中打开观众窗口，避免被弹窗拦截。只读 Slides UI 只要注册了 UI 插件并关闭编辑，也可以运行演示模式。
