Browse Source

feat: expose all versions on `player.vhs.version()` and `HlsHandler.version` (#633)

pull/643/head
Brandon Casey 6 years ago
committed by GitHub
parent
commit
a8a3322067
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      src/videojs-http-streaming.js
  2. 27
      test/videojs-http-streaming.test.js

28
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);

27
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 = '';

Loading…
Cancel
Save