mirror of
https://github.com/videojs/video.js.git
synced 2025-02-08 12:05:47 +02:00
Monkeypatch canPlayType on Android 4.0+ for HLS
Android devices starting with 4.0 can play HLS natively to some extent. However, they do not say so in the canPlayType method. This commit monkey patches canPlayType to respond with "maybe" for "application/x-mpegURL" and "application/vnd.apple.mpegURL". Otherwise, it'll fallback to the original canPlayType method.
This commit is contained in:
parent
e7b1098563
commit
e35083bc28
@ -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') {
|
||||
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){
|
||||
|
Loading…
x
Reference in New Issue
Block a user