From abdfaacd908479ff9e223621b27ae720f663e00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Petran=C3=ADk?= Date: Thu, 4 Jan 2024 15:35:23 +0100 Subject: [PATCH] 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 --- src/js/player.js | 20 ++++++++++++++++++++ test/unit/player.test.js | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/src/js/player.js b/src/js/player.js index 2594041816..5790d04ad6 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -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 * diff --git a/test/unit/player.test.js b/test/unit/player.test.js index 7f311c67a3..4feb3ea34b 100644 --- a/test/unit/player.test.js +++ b/test/unit/player.test.js @@ -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;