Hello everyone, I am glad for joining sitepoint.
So, I am patching a really crowded web radio player and sadly everything has to be patched in production mode.
<div class="hidden_element" id="hideflash">
<iframe frameBorder="0" width="315" height="45" id="flash" scrolling="no" src="THESOURCE"></iframe>
</div>
<script type="text/javascript">
var firefox = /Firefox/i.test(navigator.userAgent);
if (Modernizr.flash && !firefox) {
// Supports Flash and is not Firefox
$("#html5").addClass("is-splash");
$("#html5").addClass("is-paused");
$('video').removeAttr("autoplay");
$("#seekbar").hide();
$("#html5").hide();
}
if (firefox) {
// Firefox Detected- Normal HTML5 Initiation
document.getElementById("flash").contentDocument.close();
window.frames[0].stop();
window.frames[0].document.execCommand('Stop');
$("#hideflash").hide();
}
if (!Modernizr.flash) {
// Flash is not supported
document.getElementById("flash").contentDocument.close();
window.frames[0].stop();
window.frames[0].document.execCommand('Stop');
$("#hideflash").hide();
}
</script>
I use a Modernizr custom script to determine wether the browser is Firefox or Supports Flash. If none of this is true I unload the HTML5 Player and the flash iframe comes up as planned. If however Firefox or lack of Flash support is detected I hide the iframe and initiate the HTML5 Player.
This is a pretty problematic setup but this is the only way to meet my company’s demands. The main issue is that the code for stopping the iframe from loading sometimes works and sometimes it doesn’t.
Any suggestions on this tricky one ?
Thank you in advance.