6dcb32ce by David LaPalomento

Merge branch 'saxena-gaurav-canPlayType' into development

2 parents 8d4ab4b4 9840c6ee
......@@ -95,13 +95,7 @@ videojs.Hls.canPlaySource = function() {
videojs.HlsSourceHandler = function(mode) {
return {
canHandleSource: function(srcObj) {
var mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i;
// favor native HLS support if it's available
if (videojs.Hls.supportsNativeHls) {
return false;
}
return mpegurlRE.test(srcObj.type);
return videojs.HlsSourceHandler.canPlayType(srcObj.type);
},
handleSource: function(source, tech) {
if (mode === 'flash') {
......@@ -117,10 +111,23 @@ videojs.HlsSourceHandler = function(mode) {
});
tech.hls.src(source.src);
return tech.hls;
},
canPlayType: function(type) {
return videojs.HlsSourceHandler.canPlayType(type);
}
};
};
videojs.HlsSourceHandler.canPlayType = function(type) {
var mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i;
// favor native HLS support if it's available
if (videojs.Hls.supportsNativeHls) {
return false;
}
return mpegurlRE.test(type);
};
// register source handlers with the appropriate techs
if (videojs.MediaSource.supportsNativeMediaSources()) {
videojs.getComponent('Html5').registerSourceHandler(videojs.HlsSourceHandler('html5'));
......
......@@ -1917,6 +1917,8 @@ test('the source handler supports HLS mime types', function() {
ok(videojs.HlsSourceHandler(techName).canHandleSource({
type: 'aPplicatiOn/VnD.aPPle.MpEgUrL'
}), 'supports vnd.apple.mpegurl');
ok(videojs.HlsSourceHandler(techName).canPlayType('aPplicatiOn/VnD.aPPle.MpEgUrL'), 'supports vnd.apple.mpegurl');
ok(videojs.HlsSourceHandler(techName).canPlayType('aPplicatiOn/x-MPegUrl'), 'supports x-mpegurl');
ok(!(videojs.HlsSourceHandler(techName).canHandleSource({
type: 'video/mp4'
......@@ -1924,6 +1926,8 @@ test('the source handler supports HLS mime types', function() {
ok(!(videojs.HlsSourceHandler(techName).canHandleSource({
type: 'video/x-flv'
}) instanceof videojs.HlsHandler), 'does not support flv');
ok(!(videojs.HlsSourceHandler(techName).canPlayType('video/mp4')), 'does not support mp4');
ok(!(videojs.HlsSourceHandler(techName).canPlayType('video/x-flv')), 'does not support flv');
});
});
......