Media

Edit on Github
Open in Playground View Story

Experimental Mode

This example uses the following experimental feature: [amp-google-vrview-image]. Enable the experiment via the button below. Some components require the AMP Dev Channel to be enabled as well. Learn more here.

Enable Dev Channel

Introduction

Stories support only a subset of the media types available in AMPHTML. This samples gives an overview on which are supported.

amp-img

Images are fully supported via the amp-img extension.

Example

<amp-story-page id="amp-img">
  <amp-story-grid-layer template="fill">
    <amp-img src="https://unsplash.it/720/320/?image=10"
      grid-area="middle-third"
      width="720"
      height="320"
      layout="responsive"></amp-img>
  </amp-story-grid-layer>
  <amp-story-grid-layer template="thirds">
    <h1 grid-area="upper-third">amp-img</h1>
  </amp-story-grid-layer>
</amp-story-page>

amp-video

The only way to embed videos is currently via the amp-video extension.

Example

<amp-story-page id="amp-video">
  <amp-story-grid-layer template="fill">
    <amp-video autoplay
      loop
      grid-area="middle-third"
      width="720"
      height="960"
      poster="https://ampbyexample.com/img/story_video_dog_cover.jpg"
      layout="responsive">
      <source src="https://ampbyexample.com/video/story_video_dog.mp4"
        type="video/mp4">
    </amp-video>
  </amp-story-grid-layer>
  <amp-story-grid-layer template="thirds">
    <h1 grid-area="upper-third">amp-video</h1>
  </amp-story-grid-layer>
</amp-story-page>

Note that amp-video extension has different validation rules when used within an AMP Story—both the autoplay and poster attributes are required.

amp-audio

You can playback audio using the amp-audio component. Usually it's better to use instead the background-audio attribute on the amp-story-page element.

Example

<amp-story-page id="amp-audio">
  <amp-story-grid-layer template="fill">
    <amp-audio width="auto"
      height="50"
      autoplay
      src="https://ia801402.us.archive.org/16/items/EDIS-SRP-0197-06/EDIS-SRP-0197-06.mp3">
    </amp-audio>
  </amp-story-grid-layer>
  <amp-story-grid-layer template="thirds">
    <h1 grid-area="upper-third">amp-audio</h1>
  </amp-story-grid-layer>
</amp-story-page>

amp-gfycat

Embed animated GIFs from https://gfycat.com/.

Example

<amp-story-page id="amp-gfycat">
  <amp-story-grid-layer template="fill">
    <amp-gfycat data-gfyid="TautWhoppingCougar"
      width="640"
      height="360"
      layout="responsive">
    </amp-gfycat>
  </amp-story-grid-layer>
  <amp-story-grid-layer template="vertical">
    <h1 grid-area="upper-third">amp-gfycat</h1>
  </amp-story-grid-layer>
</amp-story-page>

amp-google-vrview-image

Stories will support 360° Media, consisting of 360° videos and images, soon. Please note that the amp-google-vrview-image component is currently experimental.

Example

<amp-story-page id="amp-google-vrview-image">
  <amp-story-grid-layer template="fill">
    <amp-google-vrview-image src="https://storage.googleapis.com/vrview/examples/coral.jpg"
      width="400"
      height="300"
      layout="responsive">
    </amp-google-vrview-image>
  </amp-story-grid-layer>
  <amp-story-grid-layer template="thirds">
    <h1 grid-area="upper-third">amp-google-vrview-image</h1>
  </amp-story-grid-layer>
</amp-story-page>