{"title":"Adding an Embed Video","id":51900,"link":"https:\/\/env.averta.net\/en\/step\/adding-an-embed-video\/","parent":[51853,51826],"content":"<p>Beside the <a href=\"https:\/\/env.averta.net\/en\/step\/adding-a-video-as-a-slide-background\/?b=51925,51925\" title=\"Adding a Video as a Slide Background\">background video<\/a>, slides support embed videos, too. Each slide can contain one slide video that adds a play button over the slide and users can start playing the video by clicking on the button. Both embedded videos (like YouTube and Vimeo videos) and self-hosted videos are supported by Master Slider.<\/p>\n<h2>Embed video<\/h2>\n<p>To add an embed video to the slide, you need to add the video URL as an anchor element with <code>ms-slide-video<\/code> class name. The anchor element should be a direct child element of the slide.<\/p>\n<pre class=\"lang:xhtml decode:true \">\t&lt;div id=\"masterslider\" class=\"master-slider\"&gt;\r\n\t\t&lt;div class=\"ms-slide\"&gt;\r\n\t\t\t&lt;a href=\"https:\/\/www.youtube.com\/watch?v=4dRR_0GzJgU\" class=\"ms-slide-video\"&gt;&lt;\/a&gt;\r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;!-- .... --&gt;\r\n\t&lt;\/div&gt;<\/pre>\n<p class=\"aswi-text-box box-info\"><strong>Note: <\/strong>Like the example above, you can set the link to the video page if the video is from YouTube or Vimeo. For other services you need to use the embed link address instead.<\/p>\n<h2>Self-hosted video<\/h2>\n<p>To add a self-hosted video as a slide video in the markup, you can define it by HTML video element. Add it as a direct child element of the slide with <code>ms-slide-video<\/code> class name. Then you need to specify the type of video player with <code>data-player-type<\/code> attribute of the video element.<\/p>\n<p>Master Slider supports <a href=\"http:\/\/www.mediaelementjs.com\/\" target=\"_blank\" rel=\"noopener\">MediaElement.js<\/a> and <a href=\"https:\/\/plyr.io\/\" target=\"_blank\" rel=\"noopener\">Plyr.js<\/a> and browsers&#8217; native players to play self-hosted videos. To set the player type for each of the supported video players, you can use the following values for <code>data-player-type<\/code> attribute.<\/p>\n<ul>\n<li><code>mejs<\/code> &#8211; Specifies MediaElement.js video player.<\/li>\n<li><code>plyr<\/code> &#8211; Specifies Plyr.js video player.<\/li>\n<li><code>native<\/code> &#8211; Determines the browser&#8217;s native video player. This type is not recommended since the native video player is not available in all browsers.<\/li>\n<\/ul>\n<p>The following example shows how to add the self-hosted video:<\/p>\n<pre class=\"lang:xhtml decode:true \">\t&lt;div id=\"masterslider\" class=\"master-slider\"&gt;\r\n\t\t&lt;div class=\"ms-slide\"&gt;\r\n\t\t\t&lt;video controls class=\"ms-slide-video\" data-player-type=\"plyr\"&gt;\r\n            \t&lt;source src=\"...\/path\/to\/video.mp4\" type=\"video\/mp4\"\/&gt;\r\n            \t&lt;source src=\"...\/path\/to\/video.ogg\" type=\"video\/ogg\"\/&gt;\r\n            &lt;\/video&gt;\r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;!-- .... --&gt;\r\n\t&lt;\/div&gt;<\/pre>\n<p class=\"aswi-text-box box-important\"><strong>Important: <\/strong>Custom video players like MediaElement.js or Plyr.js are not included in the slider source. Therefore, their assets are required to be imported to the page.<\/p>\n<h2>Autoplay<\/h2>\n<p>You can set slide video to start playing automatically. The video starts playing after selecting the slide. To enable it, you need to add <code>data-autplay=\"true\"<\/code> attribute to the video element.<\/p>\n<pre class=\"lang:xhtml decode:true \">\t&lt;div id=\"masterslider\" class=\"master-slider\"&gt;\r\n\t\t&lt;div class=\"ms-slide\"&gt;\r\n\t\t\t&lt;video controls class=\"ms-slide-video\" data-player-type=\"plyr\" data-autoplay=\"true\"&gt;\r\n            \t&lt;source src=\"...\/path\/to\/video.mp4\" type=\"video\/mp4\"\/&gt;\r\n            \t&lt;source src=\"...\/path\/to\/video.ogg\" type=\"video\/ogg\"\/&gt;\r\n            &lt;\/video&gt;\r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;div class=\"ms-slide\"&gt;\r\n\t\t\t&lt;a href=\"https:\/\/www.youtube.com\/watch?v=4dRR_0GzJgU\" class=\"ms-slide-video\" data-autoplay=\"true\"&gt;&lt;\/a&gt;\r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;!-- .... --&gt;\r\n\t&lt;\/div&gt;<\/pre>\n<p class=\"aswi-text-box box-info\"><strong>Note: <\/strong>Autoplay may not work in some mobile devices since some mobile browsers ignore it.<\/p>\n<h2>Go next after video ended<\/h2>\n<p>You can set the slider changes to the next slide after the video ends. To enable this option set <code>data-goto-next=\"true\"<\/code> attribute to the video element.<\/p>\n","type":"solution"}