{"id":9331,"date":"2022-10-06T04:56:19","date_gmt":"2022-10-06T04:56:19","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=9331"},"modified":"2022-10-06T04:56:19","modified_gmt":"2022-10-06T04:56:19","slug":"html-youtube-videos","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/10\/06\/html-youtube-videos\/","title":{"rendered":"HTML YouTube Videos"},"content":{"rendered":"\n<p>Sometimes you may want to convert your videos to other formats to make them play in all browsers. However, it can be difficult and time-consuming to convert videos to other formats. An easier way is to let YouTube play the videos on your web page.<\/p>\n\n\n\n<p>When saving or playing a video, YouTube will display an id which you can use to refer to a video in the HTML code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"playing-a-youtube-video-in-html-2\">Playing a YouTube Video in HTML<\/h2>\n\n\n\n<p>If you want to play your video on a web page, follow these steps:<\/p>\n\n\n\n<ol><li>Upload the video to YouTube<\/li><li>Take a note of the video id<\/li><li>Specify an\u00a0&lt;iframe>\u00a0element in your web page<\/li><li>Make the\u00a0src\u00a0attribute point to the video URL<\/li><li>Use the\u00a0height\u00a0and\u00a0width\u00a0attributes for defining the dimension of the player<\/li><li>Add other parameters to the URL<\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-playing-a-youtube-video-in-html-with-the-lt-iframe-gt-element-4\">Example of playing a YouTube video in HTML with the &lt;iframe&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/i8n1gSw_o_8\"&gt;&lt;\/iframe&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"youtube-autoplay-6\">YouTube Autoplay<\/h2>\n\n\n\n<p>You can also make your video start playing automatically when visiting that page. For this, add a parameter to your YouTube URL.<\/p>\n\n\n\n<p>If the value is 0 (default), the video will not start playing automatically when the player loads. If the value is 1, the video will start playing automatically when the player loads.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example of YouTube autoplay:<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\"><code>&lt;!DOCTYPE html> &lt;html> &lt;head> &lt;title>Title of the document&lt;\/title> &lt;\/head> &lt;body> &lt;iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/i8n1gSw_o_8?autoplay=1\"> &lt;\/iframe> &lt;\/body> &lt;\/html><\/code>Try it Yourself \u00bbBesides the original URL, there can be a comma separated list of videos to play (YouTube playlist).<\/h3>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"youtube-controls-10\">YouTube Controls<\/h2>\n\n\n\n<p>If the value is 0, the player controls will not display. If the value is 1(default), the player controls will display.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-youtube-controls-12\">Example of YouTube controls:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/i8n1gSw_o_8?controls=0\"&gt;\n    &lt;\/iframe&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"youtube-loop-14\">YouTube Loop<\/h2>\n\n\n\n<p>If the value is 0 (default), the video will play only once. If the value is 1, the video will loop endlessly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-youtube-loop-16\">Example of Youtube loop:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/i8n1gSw_o_8?playlist=tgbNymZ7vqY&amp;loop=1\"&gt;\n    &lt;\/iframe&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"youtube-using-the-html-lt-embed-gt-or-lt-object-gt-tags-18\">YouTube &#8211; Using the HTML &lt;embed&gt; or &lt;object&gt; tags<\/h2>\n\n\n\n<p>YouTube &lt;embed&gt; and &lt;object&gt; elements are deprecated. Instead, you should use &lt;iframe&gt;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-adding-youtube-videos-with-the-lt-embed-gt-element-20\">Example of adding YouTube videos with the &lt;embed&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;embed width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/i8n1gSw_o_8\"&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-adding-youtube-videos-with-the-lt-object-gt-element-22\">Example of adding YouTube videos with the &lt;object&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;object width=\"560\" height=\"315\" data=\"https:\/\/www.youtube.com\/embed\/i8n1gSw_o_8\"&gt;\n    &lt;\/object&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may want to convert your videos to other formats to make them play in all browsers. However, it can be difficult and time-consuming to convert videos to other formats. An easier way is to let YouTube play the videos on your web page. When saving or playing a video, YouTube will display an [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[592],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9331"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=9331"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9331\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=9331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=9331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=9331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}