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

Flash - ignore codec info - added tests for #785 #805

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/js/media/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,16 @@ 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;

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 = {
Expand Down
18 changes: 17 additions & 1 deletion test/unit/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
});

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' }));
});