3fc85b5f by David LaPalomento

Native HLS check shouldn't fail if HTML5 video isn't supported

Check if HTML video is available before trying to call canPlayType for HLS mime types.
1 parent 651a0698
......@@ -15,9 +15,18 @@ videojs.hls = {
supportsNativeHls: (function() {
var
video = document.createElement('video'),
xMpegUrl = video.canPlayType('application/x-mpegURL'),
vndMpeg = video.canPlayType('application/vnd.apple.mpegURL');
return /probably|maybe/.test(xMpegUrl) || /probably|maybe/.test(vndMpeg);
xMpegUrl,
vndMpeg;
// native HLS is definitely not supported if HTML5 video isn't
if (!videojs.Html5.isSupported()) {
return false;
}
xMpegUrl = video.canPlayType('application/x-mpegURL');
vndMpeg = video.canPlayType('application/vnd.apple.mpegURL');
return (/probably|maybe/).test(xMpegUrl) ||
(/probably|maybe/).test(vndMpeg);
})()
};
......
......@@ -26,6 +26,7 @@ var
oldFlashSupported,
oldXhr,
oldSourceBuffer,
oldSupportsNativeHls,
xhrUrls;
module('HLS', {
......@@ -41,6 +42,10 @@ module('HLS', {
this.appendBuffer = function() {};
};
// force native HLS to be ignored
oldSupportsNativeHls = videojs.hls.supportsNativeHls;
videojs.hls.supportsNativeHls = false;
// create the test player
var video = document.createElement('video');
document.querySelector('#qunit-fixture').appendChild(video);
......@@ -78,6 +83,7 @@ module('HLS', {
},
teardown: function() {
videojs.Flash.isSupported = oldFlashSupported;
videojs.hls.supportsNativeHls = oldSupportsNativeHls;
window.videojs.SourceBuffer = oldSourceBuffer;
window.XMLHttpRequest = oldXhr;
}
......@@ -631,15 +637,11 @@ test('segment 500 should trigger MEDIA_ERR_ABORTED', function () {
});
test('has no effect if native HLS is available', function() {
var supported = videojs.hls.supportsNativeHls;
videojs.hls.supportsNativeHls = true;
player.hls('manifest/master.m3u8');
ok(!(player.currentSrc() in videojs.mediaSources),
'no media source was opened');
// clean up
videojs.hls.supportsNativeHls = supported;
});
module('segment controller', {
......