#BlackLivesMatter
Do you build things with AMP? Fill out the new AMP Developer Survey!
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>
자세한 설명이 필요하신가요?

이 페이지의 설명만으로 궁금한 점이 모두 해결되지 않는다면 다른 AMP 사용자에게 문의하여 구체적인 활용 사례를 논의해 보세요.

Stack Overflow로 이동
설명이 부족한 기능을 발견하셨나요?

AMP 프로젝트는 여러분의 참여와 기여를 적극 환영합니다! 오픈 소스 커뮤니티를 통해 지속적으로 활동해 주셔도 좋지만 관심 있는 주제에 한 번만 기여하셔도 큰 도움이 됩니다.

GitHub에서 샘플 수정하기