#BlackLivesMatter
AMP
  • websites

amp-ima-video

Introduction

amp-ima-video embeds a video player for instream video ads that are integrated with the IMA SDK.

The plugin provides a video player with controls for your content, and requests and displays ads from a VAST-compliant ad server of your choice using the IMA SDK.

Setup

Import the amp-ima-video component.

<script async custom-element="amp-ima-video" src="https://cdn.ampproject.org/v0/amp-ima-video-0.1.js"></script>

Basic usage

The amp-ima-video component HTML accepts up to two unique types of HTML nodes as children - source tags for content video, and track tags for subtitles. Both of these can be used in the same way as the standard video tag.

The component requires an ad tag, provided in data-tag, which is a URL to a VAST-compliant ad response (for examples, see IMA Sample Tags). It has an optional data-poster attribute for a poster image to be displayed before playback.

<amp-ima-video id="myVideo"
  width="640"
  height="360"
  layout="responsive"
  data-tag="https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpremidpost&cmsid=496&vid=short_onecue&correlator="
  data-poster="/static/samples/img/ima-poster.jpg">
  <source src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
    type="video/mp4">
</amp-ima-video>

data-ad-label

Provide a format string in the data-ad-label attribute to customize the ad disclosure that is displayed while an ad is playing. This allows users to support ad disclosures in different languages.

A format string should look like "Ad (%s of %s)". The "%s" in the format string is replaced with the current ad number in the sequence and the total number of ads, respectively (e.g. Ad 2 of 3). If no value is given, this defaults to "Ad (%s of %s)".

<amp-ima-video id="myVideo2"
  width="640"
  height="360"
  layout="responsive"
  data-tag="https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpreonlybumper&cmsid=496&vid=short_onecue&correlator="
  data-poster="/static/samples/img/ima-poster.jpg"
  data-ad-label="Publicidad (%s de %s)">
  <source src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
    type="video/mp4">
</amp-ima-video>

Autoplay

Use the autoplay attribute to play video automatically without requiring the user to press "play".

Optionally, use data-delay-ad-request="true" to delay an ad request until either the user scrolls the page, or for 3 seconds, whichever occurs first. The default behavior of the amp-ima-video component is to request an ad on the AMP page load which has the effect of being counted as 'code served' even if there is no impression.

<amp-ima-video id="myVideo3"
  width="640"
  height="360"
  layout="responsive"
  data-tag="https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpreonlybumper&cmsid=496&vid=short_onecue&correlator="
  data-src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
  data-delay-ad-request="true"
  autoplay>
</amp-ima-video>
Besoin de plus amples explications ?

Si les explications de cette page ne répondent pas à vos questions, n'hésitez pas à contacter d'autres utilisateurs d'AMP pour discuter de votre cas d'utilisation spécifique.

Se rendre sur Stack Overflow
Une fonctionnalité n'a pas encore été expliquée ?

Le projet AMP encourage fortement votre participation et vos contributions ! Nous espérons que vous deviendrez un membre régulier de notre communauté open source, mais nous serons également ravis de recevoir des contributions ponctuelles concernant les questions qui vous intéressent particulièrement.

Modifier l'exemple sur GitHub