Skip to content

Commit abdfaac

Browse files
authored
feat: expose version from player.version() (#8543)
Add a `Player#version()` method which returns an object with the Video.js version under the `video.js` property name, to match the package name. This could then be extended to support adding plugin, tech, and source handler versions as part of the version call. Fixes #8538
1 parent 09c9bfb commit abdfaac

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/js/player.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,26 @@ class Player extends Component {
13281328
return this.tech_;
13291329
}
13301330

1331+
/**
1332+
* An object that contains Video.js version.
1333+
*
1334+
* @typedef {Object} PlayerVersion
1335+
*
1336+
* @property {string} 'video.js' - Video.js version
1337+
*/
1338+
1339+
/**
1340+
* Returns an object with Video.js version.
1341+
*
1342+
* @return {PlayerVersion}
1343+
* An object with Video.js version.
1344+
*/
1345+
version() {
1346+
return {
1347+
'video.js': version
1348+
};
1349+
}
1350+
13311351
/**
13321352
* Set up click and touch listeners for the playback element
13331353
*

test/unit/player.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,12 @@ QUnit.test('Player#tech logs a warning when called without a safety argument', f
19011901
log.warn = oldLogWarn;
19021902
});
19031903

1904+
QUnit.test('player#version will return an object with video.js version', function(assert) {
1905+
const player = TestHelpers.makePlayer();
1906+
1907+
assert.strictEqual(player.version()['video.js'], pkg.version, 'version is correct');
1908+
});
1909+
19041910
QUnit.test('player#reset loads the Html5 tech and then techCalls reset', function(assert) {
19051911
let loadedTech;
19061912
let loadedSource;

0 commit comments

Comments
 (0)