From 4a2637b7b31a88adbda3613253c155f27d9aba96 Mon Sep 17 00:00:00 2001 From: Matthew McClure Date: Wed, 16 Oct 2013 17:40:33 -0700 Subject: [PATCH 1/2] added @doublex fix for sources that contain codec information. #781 --- src/js/media/flash.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/media/flash.js b/src/js/media/flash.js index 52d756524a..5c80b2adb6 100644 --- a/src/js/media/flash.js +++ b/src/js/media/flash.js @@ -328,7 +328,8 @@ vjs.Flash.isSupported = function(){ }; vjs.Flash.canPlaySource = function(srcObj){ - if (srcObj.type in vjs.Flash.formats || srcObj.type in vjs.Flash.streamingFormats) { return 'maybe'; } + var type = srcObj.type.replace(/;.*/,''); + if (type in vjs.Flash.formats || type in vjs.Flash.streamingFormats) { return 'maybe'; } }; vjs.Flash.formats = { From ef8a9a43eecde1b05a96875ee30ef0c5e06dc5a5 Mon Sep 17 00:00:00 2001 From: Steve Heffernan Date: Tue, 29 Oct 2013 10:46:20 -0700 Subject: [PATCH 2/2] Added tests for #785 --- src/js/media/flash.js | 12 ++++++++++-- test/unit/flash.js | 18 +++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/js/media/flash.js b/src/js/media/flash.js index bf6fe03f00..5ad6ca18fe 100644 --- a/src/js/media/flash.js +++ b/src/js/media/flash.js @@ -331,8 +331,16 @@ vjs.Flash.isSupported = function(){ }; vjs.Flash.canPlaySource = function(srcObj){ - var type = srcObj.type.replace(/;.*/,''); - if (type in vjs.Flash.formats || type in vjs.Flash.streamingFormats) { return 'maybe'; } + var type; + + if (!srcObj.type) { + return ''; + } + + type = srcObj.type.replace(/;.*/,'').toLowerCase(); + if (type in vjs.Flash.formats || type in vjs.Flash.streamingFormats) { + return 'maybe'; + } }; vjs.Flash.formats = { diff --git a/test/unit/flash.js b/test/unit/flash.js index d2f91b7f7d..18c5909e35 100644 --- a/test/unit/flash.js +++ b/test/unit/flash.js @@ -45,4 +45,20 @@ test('test isStreamingSrc', function() { ok(!isStreamingSrc('http://streaming.is/fun')); ok(!isStreamingSrc('https://streaming.is/fun')); ok(!isStreamingSrc('file://streaming.is/fun')); -}); \ No newline at end of file +}); + +test('test canPlaySource', function() { + var canPlaySource = vjs.Flash.canPlaySource; + + // supported + ok(canPlaySource({ type: 'video/mp4; codecs=avc1.42E01E,mp4a.40.2' }), 'codecs supported'); + ok(canPlaySource({ type: 'video/mp4' }), 'video/mp4 supported'); + ok(canPlaySource({ type: 'video/x-flv' }), 'video/x-flv supported'); + ok(canPlaySource({ type: 'video/flv' }), 'video/flv supported'); + ok(canPlaySource({ type: 'video/m4v' }), 'video/m4v supported'); + ok(canPlaySource({ type: 'VIDEO/FLV' }), 'capitalized mime type'); + + // not supported + ok(!canPlaySource({ type: 'video/webm; codecs="vp8, vorbis"' })); + ok(!canPlaySource({ type: 'video/webm' })); +});