From d538debb1dec58599ae9f02263b102d0491d198c Mon Sep 17 00:00:00 2001 From: Steve Heffernan Date: Tue, 4 Mar 2014 09:29:09 -0800 Subject: [PATCH 1/2] Added try/catch to protect against IE with no Media Player --- src/js/media/html5.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/js/media/html5.js b/src/js/media/html5.js index bcf54ea4e2..522804b08c 100644 --- a/src/js/media/html5.js +++ b/src/js/media/html5.js @@ -237,6 +237,13 @@ vjs.Html5.prototype.defaultMuted = function(){ return this.el_.defaultMuted; }; /* HTML5 Support Testing ---------------------------------------------------- */ vjs.Html5.isSupported = function(){ + // ie9 with no Media Player is a LIAR! (#984) + try { + vjs.TEST_VID['volume'] = 0.5; + } catch (e) { + return false; + } + return !!vjs.TEST_VID.canPlayType; }; @@ -281,8 +288,13 @@ vjs.Html5.disposeMediaElement = function(el){ el.removeAttribute('src'); // force the media element to update its loading state by calling load() + // however IE on Windows 7N has a bug that throws an error so need a try/catch (#793) if (typeof el.load === 'function') { - el.load(); + try { + el.load(); + } + catch(e) { + } } }; From e4b269e294ecfdbb94ff60ac2f175be072f7696d Mon Sep 17 00:00:00 2001 From: Steve Heffernan Date: Thu, 6 Mar 2014 12:36:36 -0800 Subject: [PATCH 2/2] Added an IIFE to prevent deoptimization --- src/js/media/html5.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/js/media/html5.js b/src/js/media/html5.js index 522804b08c..0ef86fc9b0 100644 --- a/src/js/media/html5.js +++ b/src/js/media/html5.js @@ -290,11 +290,14 @@ vjs.Html5.disposeMediaElement = function(el){ // force the media element to update its loading state by calling load() // however IE on Windows 7N has a bug that throws an error so need a try/catch (#793) if (typeof el.load === 'function') { - try { - el.load(); - } - catch(e) { - } + // wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473) + (function() { + try { + el.load(); + } catch (e) { + // not supported + } + })(); } };