diff --git a/includes/amp-helper-functions.php b/includes/amp-helper-functions.php
index d8c4690568c..d22d49cec8b 100644
--- a/includes/amp-helper-functions.php
+++ b/includes/amp-helper-functions.php
@@ -260,6 +260,7 @@ function amp_get_content_embed_handlers( $post = null ) {
'AMP_Vine_Embed_Handler' => array(),
'AMP_Facebook_Embed_Handler' => array(),
'AMP_Pinterest_Embed_Handler' => array(),
+ 'AMP_Playlist_Embed_Handler' => array(),
'AMP_Reddit_Embed_Handler' => array(),
'AMP_Tumblr_Embed_Handler' => array(),
'AMP_Gallery_Embed_Handler' => array(),
diff --git a/includes/class-amp-autoloader.php b/includes/class-amp-autoloader.php
index 7bf991c8d54..3ec923b7bde 100644
--- a/includes/class-amp-autoloader.php
+++ b/includes/class-amp-autoloader.php
@@ -42,6 +42,7 @@ class AMP_Autoloader {
'AMP_Issuu_Embed_Handler' => 'includes/embeds/class-amp-issuu-embed-handler',
'AMP_Meetup_Embed_Handler' => 'includes/embeds/class-amp-meetup-embed-handler',
'AMP_Pinterest_Embed_Handler' => 'includes/embeds/class-amp-pinterest-embed',
+ 'AMP_Playlist_Embed_Handler' => 'includes/embeds/class-amp-playlist-embed-handler',
'AMP_Reddit_Embed_Handler' => 'includes/embeds/class-amp-reddit-embed-handler',
'AMP_SoundCloud_Embed_Handler' => 'includes/embeds/class-amp-soundcloud-embed',
'AMP_Tumblr_Embed_Handler' => 'includes/embeds/class-amp-tumblr-embed-handler',
diff --git a/includes/embeds/class-amp-playlist-embed-handler.php b/includes/embeds/class-amp-playlist-embed-handler.php
new file mode 100644
index 00000000000..7c799af508e
--- /dev/null
+++ b/includes/embeds/class-amp-playlist-embed-handler.php
@@ -0,0 +1,112 @@
+, and an to change the current video.
+ *
+ * @global content_width.
+ * @param array $attr The playlist attributes.
+ * @return string Playlist shortcode markup.
+ */
+ public function shortcode( $attr ) {
+ global $content_width;
+
+ $markup = wp_playlist_shortcode( $attr );
+ preg_match( '/(?s)\
+
+ [.currentVideo].videoUrl" width="" height="" controls>
+
+ $track ) {
+ if ( ! empty( $track['caption'] ) ) {
+ $title = $track['caption'];
+ } elseif ( ! empty( $track['title'] ) ) {
+ $title = $track['title'];
+ }
+ ?>
+
+
+
+
+ instance = new AMP_Playlist_Embed_Handler();
+ }
+
+ /**
+ * Tear down test.
+ */
+ public function tearDown() {
+ wp_dequeue_style( 'wp-mediaelement' );
+ }
+
+ /**
+ * Test register_embed.
+ *
+ * @covers AMP_Playlist_Embed_Handler::register_embed()
+ */
+ public function test_register_embed() {
+ global $shortcode_tags;
+ $shortcode = 'playlist';
+ $this->assertFalse( isset( $shortcode_tags[ $shortcode ] ) );
+ $this->instance->register_embed();
+ $this->assertEquals( 'AMP_Playlist_Embed_Handler', get_class( $shortcode_tags[ $shortcode ][0] ) );
+ $this->assertEquals( 'shortcode', $shortcode_tags[ $shortcode ][1] );
+ $this->instance->unregister_embed();
+ }
+
+ /**
+ * Test unregister_embed.
+ *
+ * @covers AMP_Playlist_Embed_Handler::unregister_embed()
+ */
+ public function test_unregister_embed() {
+ global $shortcode_tags;
+ $shortcode = 'playlist';
+ $this->instance->unregister_embed();
+ $this->assertFalse( isset( $shortcode_tags[ $shortcode ] ) );
+ }
+
+ /**
+ * Test shortcode.
+ *
+ * Logic for creating the upload object copied from Tests_Media.
+ *
+ * @covers AMP_Playlist_Embed_Handler::shortcode()
+ */
+ public function test_shortcode() {
+ $id_mp4 = $this->factory->attachment->create_upload_object( DIR_TESTDATA . '/uploads/small-video.mp4' );
+ $id_mkv = $this->factory->attachment->create_upload_object( DIR_TESTDATA . '/uploads/small-video.mkv' );
+ $ids = array(
+ $id_mp4,
+ $id_mkv,
+ );
+ $attr = array(
+ 'ids' => implode( ',', $ids ),
+ 'type' => 'video',
+ );
+ $playlist = $this->instance->shortcode( $attr );
+ $this->assertContains( 'assertContains( 'assertContains( 'small-video', $playlist );
+ $this->assertContains( '[src]="playlist0[playlist0.currentVideo].videoUrl"', $playlist );
+ $this->assertContains( 'on="tap:AMP.setState({playlist0: {currentVideo: 0}})"', $playlist );
+ }
+
+}