Skip to content

Commit

Permalink
feat: expose version from player.version() (#8543)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Svarozic committed Jan 4, 2024
1 parent 09c9bfb commit abdfaac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/js/player.js
Expand Up @@ -1328,6 +1328,26 @@ class Player extends Component {
return this.tech_;
}

/**
* An object that contains Video.js version.
*
* @typedef {Object} PlayerVersion
*
* @property {string} 'video.js' - Video.js version
*/

/**
* Returns an object with Video.js version.
*
* @return {PlayerVersion}
* An object with Video.js version.
*/
version() {
return {
'video.js': version
};
}

/**
* Set up click and touch listeners for the playback element
*
Expand Down
6 changes: 6 additions & 0 deletions test/unit/player.test.js
Expand Up @@ -1901,6 +1901,12 @@ QUnit.test('Player#tech logs a warning when called without a safety argument', f
log.warn = oldLogWarn;
});

QUnit.test('player#version will return an object with video.js version', function(assert) {
const player = TestHelpers.makePlayer();

assert.strictEqual(player.version()['video.js'], pkg.version, 'version is correct');
});

QUnit.test('player#reset loads the Html5 tech and then techCalls reset', function(assert) {
let loadedTech;
let loadedSource;
Expand Down

0 comments on commit abdfaac

Please sign in to comment.