> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kontext.so/llms.txt
> Use this file to discover all available pages before exploring further.

# 示例应用

> 用你自己的发布方 token 运行内置的 SwiftUI 播放器，每个视频对应一种格式。

SDK 仓库中的 [`Example`](https://github.com/kontextso/sdk-swift-video/tree/main/Example) 目录是一个小型 SwiftUI 应用，带真实的 `AVPlayer`：首页有三个视频，每个对应一种广告格式，全屏播放器展示该格式的广告。整个集成只有一个文件，`Example/Example/PlayerScreen.swift`。

## 克隆并运行

项目文件由 [XcodeGen](https://github.com/yonaskolb/XcodeGen) 生成：

```bash theme={null}
git clone https://github.com/kontextso/sdk-swift-video.git
cd sdk-swift-video/Example
brew install xcodegen
xcodegen generate
open Example.xcodeproj
```

然后在模拟器或真机上运行 `Example` scheme。

## 指向你的账号

示例使用演示 token 连接 Kontext 的广告服务器。在 `Example/Example/ExampleApp.swift` 中，把你自己的 token 填入 `Configuration`：

```swift theme={null}
let configuration = KontextVideo.Configuration(publisherToken: "<your-publisher-token>")
```

## 你会看到什么

打开一个视频：片段全屏播放，SDK 为该视频准备广告。

* **线性**：播放 3 秒后内容暂停，全屏广告播放；广告结束时内容恢复。
* **叠加**：播放 3 秒后播放器上出现一条条幅，并自行消失。
* **暂停**：点击暂停，暂停卡片出现；再点击即恢复。下一次暂停时会有新的广告就绪。

标题下方的一行显示最近一次委托回调。离开屏幕会结束该视频的广告。

## 链接

* [GitHub 上的视频 SDK](https://github.com/kontextso/sdk-swift-video)
* [示例应用](https://github.com/kontextso/sdk-swift-video/tree/main/Example)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.