{"id":47460,"date":"2019-12-22T03:01:44","date_gmt":"2019-12-21T17:01:44","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=47460"},"modified":"2019-12-21T19:13:36","modified_gmt":"2019-12-21T09:13:36","slug":"user-controlled-dynamic-javascript-youtube-embedded-api-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/user-controlled-dynamic-javascript-youtube-embedded-api-tutorial\/","title":{"rendered":"User Controlled Dynamic Javascript YouTube Embedded API Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/disco_version.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"User Controlled Dynamic Javascript YouTube Embedded API Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/disco_version.gif\" title=\"User Controlled Dynamic Javascript YouTube Embedded API Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">User Controlled Dynamic Javascript YouTube Embedded API Tutorial<\/p><\/div>\n<p>The recent <a title='Dynamic Javascript and the YouTube Embedded API Tutorial' href='#djyteapit'>Dynamic Javascript and the YouTube Embedded API Tutorial<\/a> showed the great <a target=_blank title='YouTube IFrame Player API' href='https:\/\/developers.google.com\/youtube\/iframe_api_reference'>YouTube IFrame Player API<\/a> in action, including <font size=1>&#8230; and this dovetails well into today&#8217;s work &#8230;<\/font> no advertisements.<\/p>\n<p>A lot of us will know how great <a target=_blank href='\/\/youtube.com' title='YouTube'>YouTube<\/a> playlists are.  Today, we offer a(n example of) &#8230;<\/p>\n<ul>\n<li>an up to 9 &#8220;Disco Version&#8221; random array of <a target=_blank href='\/\/youtube.com' title='YouTube'>YouTube<\/a> videos that can be played in a session &#8230;<\/li>\n<li>from a possible array of 24 table cell slots (10-24 not shown, but &#8220;duration&#8221;able behind the scenes) &#8230;<\/li>\n<li>the 15 not randomly picked available to the user in a dropdown selection they can, optionally &#8230;\n<ol>\n<li>pick one from, click a &#8220;Shuffle&#8221; button, and a randomized list of 8 others is headed by your selected video &#8230; or &#8230;<\/li>\n<li>pick more than one and the first (up to 9) forms your ordered selection of playable videos<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p> &#8230; and the progress today leaves you controlling when to play the videos, yourself, clicking <a target=_blank href='\/\/youtube.com' title='YouTube'>YouTube<\/a> play buttons to make that happen.<\/p>\n<p>Enjoy the <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/disco_version.html-GETME\" title=\"disco_version.html-GETME\">&#8220;how we got there&#8221;<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/disco_version.html-GETME\" title=\"disco_version.html-GETME\">disco_version.html<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/disco_version.html\" title=\"Click picture\">upbeat disco selection live run<\/a> link.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/user-controlled-dynamic-javascript-youtube-embedded-api-tutorial\/'>\"User Controlled Dynamic Javascript YouTube Embedded API Tutorial<\/a>.<\/p-->\n<hr>\n<p id='djyteapit'>Previous relevant <a target=_blank title='Dynamic Javascript and the YouTube Embedded API Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/dynamic-javascript-and-the-youtube-embedded-api-tutorial\/'>Dynamic Javascript and the YouTube Embedded API Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/dynamic_js.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Dynamic Javascript and the YouTube Embedded API Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/msgtw.jpg\" title=\"Dynamic Javascript and the YouTube Embedded API Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Dynamic Javascript and the YouTube Embedded API Tutorial<\/p><\/div>\n<p>Webpages without Javascript are generally pretty static and boring.  Javascript is that dynamic client addition to webpage functionality, but perhaps you only think of it as that statically written part of the webpage unable to be reloaded into effect after that initial webpage load.  Well, that is not taking into account Javascript such as &#8230;<\/p>\n<p><code><br \/>\n&lt;script&gt;<br \/>\n      var tag = document.<a target=_blank title='Javascript createElement method information from w3schools' href='https:\/\/www.w3schools.com\/jsref\/met_document_createelement.asp'>createElement<\/a>('script');<br \/>\n      tag.src = \"https:\/\/www.youtube.com\/iframe_api\";<br \/>\n      var firstScriptTag = document.getElementsByTagName('script')[0];<br \/>\n      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);<br \/>\n&lt;\/script&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; taken from the excellent <a target=_blank title='YouTube IFrame Player API' href='https:\/\/developers.google.com\/youtube\/iframe_api_reference'>YouTube IFrame Player API<\/a> we really like to use around here to embed and control <a target=_blank title='YouTube' href='https:\/\/youtube.com'>YouTube<\/a> videos embedded into an HTML <a target=_blank title='HTML iframe element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_iframe.asp'>iframe<\/a> element.<\/p>\n<p>In today&#8217;s small extension of that we load nine such HTML iframe embedded YouTube videos into a 3&#215;3 grid.  We resisted the previous <a target=_blank title='External Javascript Genericity Follow Up Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/external-javascript-genericity-follow-up-tutorial\/'>Brady Bunch usage<\/a> of such an arrangement (perhaps you&#8217;ll be sad to hear?!) in favour of showing you a &#8220;collage&#8221; of video snippets from one of my favourite films ever, <a target=_blank title='Mr Smith Goes to Washington' href='https:\/\/en.wikipedia.org\/wiki\/Mr._Smith_Goes_to_Washington'>Mr Smith Goes to Washington<\/a>.<\/p>\n<p>We hope the HTML and Javascript <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/dynamic_js.html_GETME\" title=\"dynamic_js.html\">dynamic_js.html<\/a>&#8216;s code will be food for thought, that you can test for yourself at this <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/dynamic_js.html\" title=\"Click picture\">live run<\/a> link.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d37921' onclick='var dv=document.getElementById(\"d37921\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/javascript\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d37921' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d47460' onclick='var dv=document.getElementById(\"d47460\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/music\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d47460' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The recent Dynamic Javascript and the YouTube Embedded API Tutorial showed the great YouTube IFrame Player API in action, including &#8230; and this dovetails well into today&#8217;s work &#8230; no advertisements. A lot of us will know how great YouTube &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/user-controlled-dynamic-javascript-youtube-embedded-api-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,33,37],"tags":[2539,367,2091,1683,576,3163,652,2362,1866,1891,1369,2017],"class_list":["post-47460","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-software","category-tutorials","tag-createelement","tag-dropdown","tag-duration","tag-dynamic","tag-html","tag-interaction","tag-javascript","tag-play","tag-select","tag-user","tag-video","tag-youtube-api"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/47460"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=47460"}],"version-history":[{"count":8,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/47460\/revisions"}],"predecessor-version":[{"id":47468,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/47460\/revisions\/47468"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=47460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=47460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=47460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}