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

Export videojs.Flash.embed #1533

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
1 change: 1 addition & 0 deletions src/js/exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ goog.exportSymbol('videojs.Flash', vjs.Flash);
goog.exportProperty(vjs.Flash, 'isSupported', vjs.Flash.isSupported);
goog.exportProperty(vjs.Flash, 'canPlaySource', vjs.Flash.canPlaySource);
goog.exportProperty(vjs.Flash, 'onReady', vjs.Flash['onReady']);
goog.exportProperty(vjs.Flash, 'embed', vjs.Flash.embed);

goog.exportSymbol('videojs.TextTrack', vjs.TextTrack);
goog.exportProperty(vjs.TextTrack.prototype, 'label', vjs.TextTrack.prototype.label);
Expand Down
26 changes: 25 additions & 1 deletion src/js/media/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,32 @@ vjs.Flash.version = function(){
return version.split(',');
};

// Compare Flash version. Returns -1 for lower version, 0 for same and 1 for bigger.
vjs.Flash.compareVersion = function(version){
var myVer = vjs.Flash.version(),
requiredVer = String(version).split(',');

for(var i = 0; i < 3; i++){
var myVerNum = parseInt(myVer[i], 10),
requiredVerNum = parseInt(requiredVer[i] || 0, 10);
if(myVerNum == requiredVerNum){
continue;
}else if(myVerNum > requiredVerNum){
return 1;
}else{
return -1;
}
}

return 0;
};

// Flash embedding method. Only used in non-iframe mode
vjs.Flash.embed = function(swf, placeHolder, flashVars, params, attributes){
vjs.Flash.embed = function(swf, placeHolder, flashVars, params, attributes, version){
if(version && vjs.Flash.checkVersion(version) == -1){
throw new Error('The latest Flash Player is not installed on your machine. Please go <a href="http://get.adobe.com/flashplayer/">here</a> to install it and try again.');
}

var code = vjs.Flash.getEmbedCode(swf, flashVars, params, attributes),

// Get element by embedding code and retrieving created element
Expand Down
8 changes: 8 additions & 0 deletions test/unit/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,11 @@ test('ready triggering before and after disposing the tech', function() {

vjs.Flash['checkReady'].restore();
});

test('compareVersion compares versions properly', function(){
var stub = sinon.stub(vjs.Flash, 'version').returns(['10', '1', '1']);
equal(vjs.Flash.compareVersion(11), -1);
equal(vjs.Flash.compareVersion(9), 1);
equal(vjs.Flash.compareVersion('10,1,1'), 0);
stub.restore();
});