cancel
Showing results for 
Search instead for 
Did you mean: 

Oculus Form - YouTube Embeds Without Flash

andrewtek
Expert Protege
Hi Guys,

As some of you probably saw in the news recently, FireFox temporarily removed Flash due to security vulnerabilities in the Flash plugin. While many of us probably run without Flash already; others probably experienced an explosion of websites that no longer worked (Spotify, Xfinity, HboGo, Hulu, etc). Among these, the Oculus Forum's YouTube embed feature also broke. This is because it uses the old Flash <object> embed instead of the newer HTML5 friendly <iframe> embed.

Flash Object Embed:
<object type="application/x-shockwave-flash" data="https://www.youtube.com/v/WkddF7F0zvs" width="640" height="400" title="Adobe Flash Player">
<param name="movie" value="https://www.youtube.com/v/WkddF7F0zvs">
<param name="wmode" value="transparent">
</object>

IFrame Embed:
<iframe src="//www.youtube.com/embed/WkddF7F0zvs" width="640" height="400" frameborder="0" allowfullscreen="true"></iframe>

If you have chosen to disable Flash, but you still want to see the embedded YouTube videos on this forum, I created a simple JavaScript bookmarklet that finds the Flash version of the embed code and replaces it with the IFrame version:
javascript:$("object").each(function(){var $this = $(this);var data = $this.attr("data");var i;var id;var iframe;var $iframe;if(data.indexOf("//www.youtube.com") > -1){i = data.lastIndexOf("/") + 1;id = data.substring(i);if(id.length > 0){$iframe = $(iframe = document.createElement("iframe"));$iframe.attr({src: "//www.youtube.com/embed/" + id, width:$this.attr("width"),height:$this.attr("height"),frameborder: 0, allowfullscreen:true,});$this.replaceWith($iframe);}}});

There may be a dozen other ways to do this, but this was quick and simple. Technically, you could use the above javascript on any site that is using jQuery to get their videos to show up.

Also, Oculus could wrap the above code in a script tag and drop it in their forum template just above the closing body tag to automatically upgrade their pages to using the IFrame embed. Or even better, modify the YouTube embed markup to use the IFrame version and avoid needing any javascript altogether.

NOTE: Never use a javascript that you do not understand. The above javascript is purposefully simple to allow those familiar with javascript and the jQuery API to audit it.
2 REPLIES 2

cybereality
Grand Champion
Thanks, andrewtek. I've just updated the code.
AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV

andrewtek
Expert Protege
Wow! Thanks Cybereality!