Description Displays a YouTube video.
Required Script <script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"></script>
Supported Layouts fill, fixed, fixed-height, flex-item, nodisplay, responsive
Examples Annotated code example for amp-youtube

Example

With the responsive layout, the width and height from the example should yield correct layouts for 16:9 aspect ratio videos:

<amp-youtube
    data-videoid="mGENRKrdoGY"
    layout="responsive"
    width="480" height="270"></amp-youtube>

Attributes

autoplay

If this attribute is present, and the browser supports autoplay:

  • the video is automatically muted before autoplay starts
  • when the video is scrolled out of view, the video is paused
  • when the video is scrolled into view, the video resumes playback
  • when the user taps the video, the video is unmuted
  • if the user has interacted with the video (e.g., mutes/unmutes, pauses/resumes, etc.), and the video is scrolled in or out of view, the state of the video remains as how the user left it. For example, if the user pauses the video, then scrolls the video out of view and returns to the video, the video is still paused.

data-videoid

The YouTube video id found in every YouTube video page URL.

For example, in this URL: https://www.youtube.com/watch?v=Z1q71gFeRqM, Z1q71gFeRqM is the video id.

data-param-*

All data-param-* attributes will be added as query parameter to the YouTube iframe src. This may be used to pass custom values through to YouTube plugins, such as whether to show controls.

Keys and values will be URI encoded. Keys will be camel cased.

  • data-param-controls=1 becomes &controls=1

See YouTube Embedded Player Parameters for more parameter options for YouTube.

common attributes

This element includes common attributes extended to AMP components.

Validation

See amp-youtube rules in the AMP validator specification.