> ## 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.

# 运行你自己的竞价

> 在广告渲染前把价格与其他广告网络比较，然后加载或拒绝它。

`VideoAd` 在渲染前就带着价格，所以你可以和其他广告网络比较后再决定：

```kotlin theme={null}
val ad = ads.format(AdFormat.PAUSE)
if (ad.price.value >= otherNetworkCpm) {
    ad.load()
    pauseAd = ad
} else {
    try {
        ad.reject(VideoAd.RejectReason.Outbid(winningPrice = otherNetworkCpm, winner = "Other network"))
    } catch (e: VideoAdException) {
        // 广告已经结束（已过期）：无需告知
    }
}
```

`price.value` 是以 `price.currency` 计的 CPM。`price.precision` 说明它是广告主的成交价（`EXACT`）还是自有需求的预估（`ESTIMATED`）。

`reject` 立即告知服务器，服务器告诉广告主其胜出未产生曝光。另一个广告网络以价格胜出时用 `Outbid` 并带上胜出价格和广告网络，让我们能针对你的流量优化出价；其他任何原因用 `NotUsed`（默认）：时机过了、观众离开了。拒绝是可选的；你从未使用的广告会在过期或你调用 `destroy()` 时结算。


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