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

# 同时加载多个广告

> 要同时准备多种格式，并发地请求并加载它们。

要同时准备多种格式，并发地请求并加载它们。每种格式并行请求和渲染，某种格式没有广告不会影响其他格式：

```kotlin theme={null}
suspend fun prepare(format: AdFormat): VideoAd? = try {
    ads.format(format).also {
        it.load()
        it.listener = this
    }
} catch (e: VideoAdException) {
    null                                   // 这次该格式无填充
}

lifecycleScope.launch {
    val overlay = async { prepare(AdFormat.OVERLAY) }
    val pause = async { prepare(AdFormat.PAUSE) }
    val linear = async { prepare(AdFormat.LINEAR) }
    overlayAd = overlay.await()
    pauseAd = pause.await()
    linearAd = linear.await()
}
```


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