From a8a332206741cae1cdb4719c0ecfbb945e3be93c Mon Sep 17 00:00:00 2001 From: Brandon Casey <2381475+brandonocasey@users.noreply.github.com> Date: Mon, 19 Aug 2019 16:34:53 -0400 Subject: [PATCH] feat: expose all versions on `player.vhs.version()` and `HlsHandler.version` (#633) --- src/videojs-http-streaming.js | 28 ++++++++++++++++++++++++++-- test/videojs-http-streaming.test.js | 27 +++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index 546c1972..f821efca 100644 --- a/src/videojs-http-streaming.js +++ b/src/videojs-http-streaming.js @@ -28,7 +28,11 @@ import { comparePlaylistBandwidth, comparePlaylistResolution } from './playlist-selectors.js'; -import { version } from '../package.json'; +import {version as vhsVersion} from '../package.json'; +import {version as muxVersion} from 'mux.js/package.json'; +import {version as mpdVersion} from 'mpd-parser/package.json'; +import {version as m3u8Version} from 'm3u8-parser/package.json'; +import {version as aesVersion} from 'aes-decrypter/package.json'; // import needed to register middleware import './middleware-set-current-time'; @@ -713,6 +717,26 @@ class HlsHandler extends Component { } } + /** + * return the version + */ + static version() { + return { + '@videojs/http-streaming': vhsVersion, + 'mux.js': muxVersion, + 'mpd-parser': mpdVersion, + 'm3u8-parser': m3u8Version, + 'aes-decrypter': aesVersion + }; + } + + /** + * return the version + */ + version() { + return this.constructor.version(); + } + /** * Begin playing the video. */ @@ -799,7 +823,7 @@ class HlsHandler extends Component { */ const HlsSourceHandler = { name: 'videojs-http-streaming', - VERSION: version, + VERSION: vhsVersion, canHandleSource(srcObj, options = {}) { const localOptions = videojs.mergeOptions(videojs.options, options); diff --git a/test/videojs-http-streaming.test.js b/test/videojs-http-streaming.test.js index 210a7c17..b89c726f 100644 --- a/test/videojs-http-streaming.test.js +++ b/test/videojs-http-streaming.test.js @@ -32,6 +32,12 @@ import window from 'global/window'; // we need this so the plugin registers itself import 'videojs-contrib-quality-levels'; +import {version as vhsVersion} from '../package.json'; +import {version as muxVersion} from 'mux.js/package.json'; +import {version as mpdVersion} from 'mpd-parser/package.json'; +import {version as m3u8Version} from 'm3u8-parser/package.json'; +import {version as aesVersion} from 'aes-decrypter/package.json'; + let testOrSkip = 'test'; // some tests just don't work reliably on ie11 or edge @@ -106,6 +112,27 @@ QUnit.module('HLS', { } }); +QUnit.test('version is exported', function(assert) { + this.player.src({ + src: 'manifest/playlist.m3u8', + type: 'application/vnd.apple.mpegurl' + }); + + this.clock.tick(1); + + assert.ok(this.player.vhs.version, 'version function'); + assert.ok(videojs.HlsHandler.version, 'version function'); + + assert.deepEqual(this.player.vhs.version(), { + '@videojs/http-streaming': vhsVersion, + 'mux.js': muxVersion, + 'mpd-parser': mpdVersion, + 'm3u8-parser': m3u8Version, + 'aes-decrypter': aesVersion + }, 'version is correct'); + +}); + QUnit.test('deprecation warning is show when using player.hls', function(assert) { const oldWarn = videojs.log.warn; let warning = '';