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

Monkeypatch canPlayType on Android 4.0+ for HLS #1084

Merged
merged 14 commits into from
Mar 26, 2014
14 changes: 14 additions & 0 deletions src/js/media/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,20 @@ vjs.Html5.disposeMediaElement = function(el){

// HTML5 Feature detection and Device Fixes --------------------------------- //

// Android 4.0 and above can play HLS to some extent but it reports being unable to do so
if (vjs.ANDROID_VERSION >= 4.0) {
(function() {
var canPlayType = HTMLVideoElement.prototype.canPlayType;

HTMLVideoElement.prototype.canPlayType = function(type) {
if (type && type === 'application/x-mpegURL' || type === 'application/vnd.apple.mpegURL') {
Copy link
Member

Choose a reason for hiding this comment

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

I was called out on this one... I think this should technically be a case-insensitive match.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not only that but the official mimetype is all lowercase: http://tools.ietf.org/html/draft-pantos-http-live-streaming-12#section-10

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed.

return "maybe";
}
return canPlayType.call(video.constructor.prototype, type);
}
})();
}

// Override Android 2.2 and less canPlayType method which is broken
if (vjs.IS_OLD_ANDROID) {
document.createElement('video').constructor.prototype.canPlayType = function(type){
Expand Down