Skip to content

Commit

Permalink
Merge pull request #109 from kylevv/master
Browse files Browse the repository at this point in the history
Fix setAdVolume and attempt to build
  • Loading branch information
kylevv authored Dec 3, 2018
2 parents 9e5696e + 3abf5d9 commit 53e28da
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/vpaid-ad.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const webpack = require('./webpack.config.js')
const browsers = process.env.CI ? ['ChromeHeadless'] : ['Chrome']
const browsers = !process.env.CI ? ['Chrome'] : ['ChromeHeadlessNoSandbox']
const customLaunchers = !process.env.CI ? {} : {
// Workaround for permissions issues running Chrome with sandbox in docker
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
}
module.exports = function (config) {
config.set({
basePath: '.',
Expand All @@ -24,6 +31,7 @@ module.exports = function (config) {
}
],
browsers,
customLaunchers,
webpack,
reporters: ['progress', 'coverage'],
coverageReporter: {
Expand Down
3 changes: 2 additions & 1 deletion lib/linear.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ function (_TinyEmitter) {
}, {
key: "setAdVolume",
value: function setAdVolume(volume) {
if (this.previousAttributes.volume === volume) {
if (this._attributes.volume === volume) {
// no change, no fire
return;
}
Expand All @@ -522,6 +522,7 @@ function (_TinyEmitter) {

this.set('volume', volume);
this._videoSlot.volume = volume;
this._videoSlot.muted = !volume;
this.emit('AdVolumeChange');
}
}, {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "vpaid-ad",
"version": "4.0.4",
"version": "4.0.5",
"description": "VPAID ad class for extending purposes.",
"main": "lib/index.js",
"scripts": {
"lint": "standard",
"babel": "./node_modules/.bin/babel -d lib src",
"build": "npm run lint && npm run babel && webpack",
"build": "npm run lint && npm run babel && webpack --mode=production",
"test": "cross-env NODE_ENV=test karma start",
"coveralls": "cat ./coverage/report-lcov/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
},
Expand Down
3 changes: 2 additions & 1 deletion src/linear.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class Linear extends TinyEmitter {
* @param {number} volume between 0 and 1
*/
setAdVolume (volume) {
if (this.previousAttributes.volume === volume) {
if (this._attributes.volume === volume) {
// no change, no fire
return
}
Expand All @@ -411,6 +411,7 @@ class Linear extends TinyEmitter {
}
this.set('volume', volume)
this._videoSlot.volume = volume
this._videoSlot.muted = !volume
this.emit('AdVolumeChange')
}

Expand Down
1 change: 1 addition & 0 deletions tests/linear-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ describe('Linear', function () {
linear1.subscribe(function () {
done()
}, 'AdStarted')
linear1.setAdVolume(0) // to ensure autoplay works
linear1.startAd()
})

Expand Down
2 changes: 2 additions & 0 deletions tests/video-tracker-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ describe('VideoTracker', function () {
tracker2 = new VideoTracker(videoSlot2, emitter2, 'AdVideo')
videoSlot1.src = '/base/tests/fixtures/xbox-one.mp4'
videoSlot2.src = '/base/tests/fixtures/xbox-one.mp4'
videoSlot1.volume = videoSlot2.volume = 0
videoSlot1.muted = videoSlot2.muted = true
document.body.appendChild(videoSlot1)
document.body.appendChild(videoSlot2)
})
Expand Down

0 comments on commit 53e28da

Please sign in to comment.