Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added try/catch to protect against IE with no Media Player. Fixes #984 #1060

Merged
merged 2 commits into from
Mar 6, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/js/media/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we wrap this in a function to make sure that disposeMediaElement isn't deoptimized by js engines for having a try/catch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would that look like?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um... either as just an IIFE or a whole separate function we call here. An IIFE is probably good.

if (typeof el.load === 'function') {
  (function() {
    try {
      el.load();
    } catch (e) {
      // not supported
    }
  })();
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah, I was thinking about the isSupported one. And I'm guessing it's not worth doing the same there, yeah?

I'll add this in. What would the negative affects be of deoptimization? Just slower processing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De-optimized code runs in the js interpreter so it's significantly slower.

el.load();
}
catch(e) {
}
}
};

Expand Down