# Advertising before video

Mini Program advertising traffic main operating guidelines:Document address
The developer can be video Add property configuration to the component, create a Mini Program video advertising component, video advertising component after the creation will automatically pull advertising data, display advertising before the video playback.

# Advertising style

Display style in the video component set by the developer, at a scale of 16 to 9, vertical or horizontal center

# Advertising creation

invideo The following advertising-related property configurations have been added to the component, setting theAd-unit-idThen you can display the corresponding ads

attribute type Default value Required Introductions
Ad-unit-id string yes The ad unit ID can be created in the main traffic module of the Mini Program management background
bindadload eventhandle no Callback for Ad Load Success
Binding error eventhandle no Advertisement load failed callback, return code sameadassembly
bindclose eventhandle no Callback for Ad Closure
Bindadplay eventhandle no Ad Start, End Play Callback event.detail = {type: 'begin/end'}

Add ad units, bind ad events

<video 
  class="xxx"
  src="xxx"
  bindadplay="onAdplay" 
  bindadload="onAdload"
  bindadclose="onAdclose" 
  bindaderror="onAdError" 
  ad-unit-id="xxx" 
>
</video>

Monitoring advertising events

Page({
  onAdplay (e) {
    console.log('onAdplay',  e)
  },
  onAdload(e){
    console.log('onAdload', e)
  },
  onAdclose(e) {
    console.log('onAdclose',  e)
  },
  onAdError(e) {
    console.log('onAdError', e)
  },
})

# Advertising preload

Developers can call wx.preloadVideoAd The way advertising is preloaded


const adUnitId1 = 'xxx' 
const adUnitId2 = 'xxx' 
wx.preloadVideoAd([adUnitId1, adUnitId2])

# Error code

The error code is the error message obtained by the bindaderror callback.General Advertising ComponentsadThe following error codes have been added to the error codes.

code Unusual circumstances Solutions
3001 Hit frequency control strategy According to no advertising processing
3002 Hit frequency control strategy According to no advertising processing
3003 Hit frequency control strategy According to no advertising processing
3004 Hit frequency control strategy According to no advertising processing

# Note

1, support video preload capacity:Document address

  1. Only video components in the same layer rendering mode are supported.

3, the developer can monitor the bindadplay event to get the advertising playback status, and make corresponding processing.

4, ad-unit-id does not support asynchronous settings, only support settings in the wxml or js fileDataProperty, throughsetDataInvalid setting.

5, full screen mode does not display the video before posting ads.