{"id":3074,"date":"2011-10-21T18:26:12","date_gmt":"2011-10-21T22:26:12","guid":{"rendered":"http:\/\/richard.rathe.org\/?p=3074"},"modified":"2012-06-24T08:44:37","modified_gmt":"2012-06-24T12:44:37","slug":"video-script-that-degrades-gracefully","status":"publish","type":"post","link":"https:\/\/redmangrove.org\/rathe.org\/richard\/2011\/video-script-that-degrades-gracefully","title":{"rendered":"A Video Script That Degrades Gracefully"},"content":{"rendered":"<p>A few years ago I was looking for a clean way to embed <strong>mp4 video<\/strong> into my blog. Prior to <strong>HTML5<\/strong> the best approach was a\u00a0<strong>Flash-based video player<\/strong>. Of course there is <strong>no Flash on iPhones<\/strong> and similar devices. Plus many people avoid Flash because of bugs and security concerns. So I modified this script so it\u00a0<strong>defaults to JWPlayer when Flash is present<\/strong>&#8230;<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3083 alignnone\" title=\"with-flash\" src=\"http:\/\/richard.rathe.org\/wp-content\/uploads\/2011\/10\/with-flash.jpg\" alt=\"\" width=\"369\" height=\"337\" srcset=\"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-content\/uploads\/2011\/10\/with-flash.jpg 369w, https:\/\/redmangrove.org\/rathe.org\/richard\/wp-content\/uploads\/2011\/10\/with-flash-150x136.jpg 150w, https:\/\/redmangrove.org\/rathe.org\/richard\/wp-content\/uploads\/2011\/10\/with-flash-273x250.jpg 273w\" sizes=\"auto, (max-width: 369px) 85vw, 369px\" \/><\/p>\n<p>&#8230;but degrades gracefully into a <strong>screen shot linked to the mp4 when Flash is absent<\/strong>&#8230;<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3080 alignnone\" title=\"no-flash\" src=\"http:\/\/richard.rathe.org\/wp-content\/uploads\/2011\/10\/no-flash.jpg\" alt=\"\" width=\"320\" height=\"480\" srcset=\"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-content\/uploads\/2011\/10\/no-flash.jpg 320w, https:\/\/redmangrove.org\/rathe.org\/richard\/wp-content\/uploads\/2011\/10\/no-flash-100x150.jpg 100w, https:\/\/redmangrove.org\/rathe.org\/richard\/wp-content\/uploads\/2011\/10\/no-flash-166x250.jpg 166w\" sizes=\"auto, (max-width: 320px) 85vw, 320px\" \/><\/p>\n<p>&#8230;and displays the video in a separate window or helper app&#8230;<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3079 alignnone\" title=\"no-flash2\" src=\"http:\/\/richard.rathe.org\/wp-content\/uploads\/2011\/10\/no-flash2.jpg\" alt=\"\" width=\"480\" height=\"320\" srcset=\"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-content\/uploads\/2011\/10\/no-flash2.jpg 480w, https:\/\/redmangrove.org\/rathe.org\/richard\/wp-content\/uploads\/2011\/10\/no-flash2-150x100.jpg 150w, https:\/\/redmangrove.org\/rathe.org\/richard\/wp-content\/uploads\/2011\/10\/no-flash2-375x250.jpg 375w\" sizes=\"auto, (max-width: 480px) 85vw, 480px\" \/><\/p>\n<p style=\"text-align: center;\">[<a href=\"http:\/\/richard.rathe.org\/boundary-waters-canoe-trip-2011\/\" target=\"_blank\">see the script in action<\/a>]<\/p>\n<p>The code appears below. You must replace all the <strong>&#8220;V_&#8221;\u00a0placeholders<\/strong> with specific information about the video. The path to the player software should be adjusted to match your configuration. <strong>The &lt;div&gt; ID should be unique<\/strong> on your site to prevent collisions. This setup assumes there is a <strong>jpg key frame file<\/strong> with the same V_NAME as the mp4. Make sure you <strong>adjust the size<\/strong> to suit your needs. I find that <strong>320&#215;240<\/strong> works well embedded in a content area 500-600 pixels wide. The actual mp4 is <strong>640&#215;480<\/strong>, which looks pretty good even when expanded to full screen.<\/p>\n<p>How does it work? Basically the script attempts to load the player and <strong>write the display code<\/strong> into the &lt;div&gt; container. If it fails, the <strong>default &lt;div&gt; contents are displayed instead<\/strong>\u00a0(key frame and link). &lt;smile&gt;<\/p>\n<pre>&lt;script src=\"\/jw\/swfobject.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n\r\n&lt;div id=\"V_DIV\" style=\"text-align: center;\"&gt;\r\n&lt;a href=\"\/wp-content\/videos\/V_NAME.mp4\" target=\"_blank\"&gt;\r\n&lt;img src=\"\/wp-content\/videos\/V_NAME.jpg\" alt=\"\" \/&gt;\r\n&lt;\/a&gt;&lt;br \/&gt;V_SIZE Mb Video\r\n&lt;\/div&gt;\r\n\r\n&lt;script type=\"text\/javascript\"&gt; var so = new SWFObject('\/jw\/player.swf','mpl','320','240','9');\r\nso.addParam('allowfullscreen','true');\r\nso.addParam('allowscriptaccess','never');\r\nso.addParam('wmode','opaque');\r\nso.addVariable('controlbar','over');\r\nso.addVariable('autostart','false');\r\nso.addVariable('file','\/wp-content\/videos\/V_NAME.mp4');\r\nso.addVariable('image','\/wp-content\/videos\/V_NAME.jpg');\r\nso.addVariable('title','V_TITLE');\r\nso.addVariable('author','V_AUTHOR');\r\nso.write('V_DIV');\r\n&lt;\/script&gt;<\/pre>\n<p>[Note that if you cut and paste the code above you should remove most of the line breaks I added to make it display properly.]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few years ago I was looking for a clean way to embed mp4 video into my blog. Prior to HTML5 the best approach was a\u00a0Flash-based video player. Of course there is no Flash on iPhones and similar devices. Plus many people avoid Flash because of bugs and security concerns. So I modified this script &hellip; <a href=\"https:\/\/redmangrove.org\/rathe.org\/richard\/2011\/video-script-that-degrades-gracefully\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;A Video Script That Degrades Gracefully&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,30],"tags":[],"class_list":["post-3074","post","type-post","status-publish","format-standard","hentry","category-programming","category-video"],"_links":{"self":[{"href":"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-json\/wp\/v2\/posts\/3074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-json\/wp\/v2\/comments?post=3074"}],"version-history":[{"count":22,"href":"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-json\/wp\/v2\/posts\/3074\/revisions"}],"predecessor-version":[{"id":3076,"href":"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-json\/wp\/v2\/posts\/3074\/revisions\/3076"}],"wp:attachment":[{"href":"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-json\/wp\/v2\/media?parent=3074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-json\/wp\/v2\/categories?post=3074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redmangrove.org\/rathe.org\/richard\/wp-json\/wp\/v2\/tags?post=3074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}