# Weixin Mini Program Video advertising

Weixin Mini Program Ad Traffic Master Operating Instructions: Document Address Developers can use the ad component to create the Weixin Mini Program video ad component, which automatically pulls ad data and displays it when created.For the time being, it is only supported in the same-layer rendering mode, and it does not support nested use.

# Advertising Size Settings

Weixin Mini Program Video ads do not allow direct style attributes to be set. The default width is 100% (width: 100%), and the height is automatically proportionalized, so developers can set the width of the outer components of the ads to adjust the size of the ads. The width of the advertising outer layer component is not allowed to be less than 90% of the screen width. When the width is less than 90%, the width of a video advertising component is forced to be 90% of the width.

/* 外层组件的宽度可设置成100%或具体数值 */
.adContainer {
  width: 100%;
}
<view class="adContainer">
  <ad unit-id="xxxx" ad-type="video" ad-theme="white"></ad>
</view>

# Advertising Theme Style Setting

Weixin Mini Program The video ad component provides both black and white theme styles that developers can pass in when creating video adsThead-themeargument is a character string.white,black

<view class="adContainer">
  <ad unit-id="xxxx" ad-type="video" ad-theme="white"></ad>
</view>
<view class="adContainer">
  <ad unit-id="xxxx" ad-type="video" ad-theme="black"></ad>
</view>

# Advertising incident listening

Video ads automatically pull ads once they are created.Developers can use the ad component toonloadandonerrorevent listening ads pull successfully or fail, and can be closed byoncloseeventlistening ads.

<view class="adContainer">
  <ad unit-id="xxxx" ad-type="video" ad-theme="white" bindload="adLoad" binderror="adError" bindclose="adClose"></ad>
</view>
Page({
  adLoad() {
    console.log('小程序视频广告加载成功')
  },
  adError(err) {
    console.log('小程序视频广告加载失败', err)
  },
  adClose() {
    console.log('小程序视频广告关闭')
  }
})

# Ads are refreshed on a regular basis

Weixin Mini Program Video ad component not suitable for timed refresh parametersad-intervals