Skip to content

Commit

Permalink
chore: video.js 5/6 compatibility and travis update (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Feb 9, 2017
1 parent b6d0a10 commit c69ac5d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
29 changes: 23 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
sudo: false
dist: trusty
language: node_js
node_js:
- 'node'
- '4.4'
- '0.12'
- '0.10'

- 'lts/argon'
before_script:

# Set up a virtual screen for Firefox.
# check if the current version is equal to the version for the env
- 'export IS_INSTALLED="$(npm list video.js | grep "video.js@$VJS")"'
# we have to add semi colons to the end of each line in the if
# as travis runs this all on one line
- 'if [ -z "$IS_INSTALLED" ]; then
echo "INSTALLING video.js@>=$VJS.0.0-RC.0 <$(($VJS+1)).0.0";
npm i "video.js@>=$VJS.0.0-RC.0 <\$(($VJS+1)).0.0";
else
echo "video.js@$VJS ALREADY INSTALLED";
fi'
- export CHROME_BIN=/usr/bin/google-chrome
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
env:
- VJS=5
- VJS=6
addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
5 changes: 4 additions & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import videojs from 'video.js';
import QualityLevelList from './quality-level-list.js';

// vjs 5/6 support
const registerPlugin = videojs.registerPlugin || videojs.plugin;

/**
* Initialization function for the qualityLevels plugin. Sets up the QualityLevelList and
* event handlers.
Expand Down Expand Up @@ -44,7 +47,7 @@ const qualityLevels = function(options) {
};

// Register the plugin with video.js.
videojs.plugin('qualityLevels', qualityLevels);
registerPlugin('qualityLevels', qualityLevels);

// Include the version number.
qualityLevels.VERSION = '__VERSION__';
Expand Down
9 changes: 7 additions & 2 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function(config) {

// On Travis CI, we can only run in Firefox.
if (process.env.TRAVIS) {
config.browsers = ['Firefox'];
config.browsers = ['Firefox', 'travisChrome'];
}

// If no browsers are specified, we enable `karma-detect-browsers`
Expand All @@ -26,7 +26,12 @@ module.exports = function(config) {
'node_modules/video.js/dist/video-js.css',
'test/dist/bundle.js'
],

customLaunchers: {
travisChrome: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
detectBrowsers: detectBrowsers,
reporters: ['dots'],
port: 9876,
Expand Down
4 changes: 2 additions & 2 deletions test/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ QUnit.module('videojs-contrib-quality-levels', {

QUnit.test('registers itself with video.js', function(assert) {
assert.strictEqual(
Player.prototype.qualityLevels,
plugin,
typeof Player.prototype.qualityLevels,
'function',
'videojs-contrib-quality-levels plugin was registered'
);
});

0 comments on commit c69ac5d

Please sign in to comment.