> ## 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 运行内置的 ExoPlayer 应用，每个视频对应一种格式。

SDK 仓库中的 [`example`](https://github.com/kontextso/sdk-kotlin-video/tree/main/example) 目录是一个小型 Android 应用，带真实的 `ExoPlayer`：首页有四个视频，每个对应一种广告格式（暂停广告分卡片和全屏两种），全屏播放器展示该视频的广告。整个集成只有一个文件，`example/src/main/kotlin/so/kontext/video/example/PlayerActivity.kt`。

## 克隆并运行

你需要 JDK 17、带 platform 35 的 Android SDK，以及 Android 7.0 或更高版本的模拟器或真机：

```bash theme={null}
git clone https://github.com/kontextso/sdk-kotlin-video.git
cd sdk-kotlin-video
./gradlew :example:installDebug
```

或者在 Android Studio 中打开项目并运行 `example` 模块。给模拟器 4 GB 或更多内存：播放器和广告的 WebView 会同时运行。

## 指向你的账号

示例使用演示 token 连接 Kontext 的广告服务器。在 `example/src/main/kotlin/so/kontext/video/example/ExampleApp.kt` 中，把你自己的 token 填入 `Configuration`：

```kotlin theme={null}
KontextVideo.initialize(this, Configuration("<your-publisher-token>") { logLevel = Configuration.LogLevel.DEBUG })
```

## 你会看到什么

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

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

标题上方的一行先显示广告就绪时的价格，然后显示最近一次监听器回调。离开屏幕会结束该视频的广告。`adb logcat -s KontextVideo` 显示 SDK 的日志。

## 链接

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


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