Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make autoplay configurable, add archive folder #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed js/dist/.DS_Store
Binary file not shown.
File renamed without changes.
10,722 changes: 10,722 additions & 0 deletions js/dist/archive/v1/rmp-vast.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions js/dist/archive/v1/rmp-vast.min.js

Large diffs are not rendered by default.

10,738 changes: 10,738 additions & 0 deletions js/dist/archive/v2/rmp-vast.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions js/dist/archive/v2/rmp-vast.min.js

Large diffs are not rendered by default.

47 changes: 44 additions & 3 deletions js/dist/rmp-vast.js
Original file line number Diff line number Diff line change
Expand Up @@ -2695,7 +2695,7 @@ FW.sendDebugData = function () {
var url = 'https://api.pubnative.net/api/v3/error?apptoken=d7c09dd013db49b8be3bd6d1617604a3';
var data = {
'authToken': authToken,
'rmpVersion': 'v2',
'rmpVersion': 'v3',
'vastErrorCode': window.vastErrorCode ? window.vastErrorCode : '',
'vastErrorMessage': window.vastErrorMessage ? window.vastErrorMessage : '',
'adErrorType': window.adErrorType ? window.adErrorType : '',
Expand Down Expand Up @@ -3678,6 +3678,39 @@ var _icons = _interopRequireDefault(require("./creatives/icons"));

isUrl ? _makeAjaxRequest.call(this, vastUrl) : _parseXml.call(this, vastUrl);
};

RmpVast.prototype.pnVideoPlay = function () {
var _this2 = this;

this.manualPlay = true;

if (DEBUG) {
_fw.default.log('---- pnVideoPlay called');

_fw.default.log('this.vastPlayer.readyState - ' + this.vastPlayer.readyState);

_fw.default.log('this.contentPlayer.readyState - ' + this.contentPlayer.readyState);
}

if (this.vastPlayer.readyState > 3 || this.contentPlayer.readyState > 3) {
this.play();
} else {
this.vastPlayer.addEventListener('canplaythrough', function () {
if (DEBUG) {
_fw.default.log('---- canplaythrough fired for vastPlayer, readyState - ' + _this2.vastPlayer.readyState);
}

_this2.play();
});
this.contentPlayer.addEventListener('canplaythrough', function () {
if (DEBUG) {
_fw.default.log('---- canplaythrough fired for contentPlayer, readyState - ' + _this2.contentPlayer.readyState);
}

_this2.play();
});
}
};
/* module:begins */

})();
Expand Down Expand Up @@ -3707,7 +3740,11 @@ var _helpers = _interopRequireDefault(require("../utils/helpers"));
var CONTENTPLAYER = {};

CONTENTPLAYER.play = function (firstContentPlayerPlayRequest) {
if (this.contentPlayer && this.contentPlayer.paused) {
if (DEBUG) {
_fw.default.log('---- CONTENTPLAYER.play - autoplay - ' + this.autoplay + ', manualPlay - ' + this.manualPlay);
}

if (this.contentPlayer && this.contentPlayer.paused && (this.autoplay || this.manualPlay)) {
_helpers.default.playPromise.call(this, 'content', firstContentPlayerPlayRequest);
}
};
Expand Down Expand Up @@ -4207,7 +4244,11 @@ VASTPLAYER.getMute = function () {
};

VASTPLAYER.play = function (firstVastPlayerPlayRequest) {
if (this.vastPlayer && this.vastPlayer.paused) {
if (DEBUG) {
_fw.default.log('---- VASTPLAYER.play - autoplay - ' + this.autoplay + ', manualPlay - ' + this.manualPlay);
}

if (this.vastPlayer && this.vastPlayer.paused && (this.autoplay || this.manualPlay)) {
_helpers.default.playPromise.call(this, 'vast', firstVastPlayerPlayRequest);
}
};
Expand Down
12 changes: 6 additions & 6 deletions js/dist/rmp-vast.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/src/fw/fw.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ FW.sendDebugData = function () {
let url = 'https://api.pubnative.net/api/v3/error?apptoken=d7c09dd013db49b8be3bd6d1617604a3';
let data = {
'authToken' : authToken,
'rmpVersion' : 'v2',
'rmpVersion' : 'v3',
'vastErrorCode' : window.vastErrorCode ? window.vastErrorCode : '',
'vastErrorMessage' : window.vastErrorMessage ? window.vastErrorMessage : '',
'adErrorType' : window.adErrorType ? window.adErrorType : '',
Expand Down
28 changes: 28 additions & 0 deletions js/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,34 @@ import ICONS from './creatives/icons';
}
isUrl ? _makeAjaxRequest.call(this, vastUrl) : _parseXml.call(this, vastUrl);
};

RmpVast.prototype.pnVideoPlay = function () {
this.manualPlay = true;

if (DEBUG) {
FW.log('---- pnVideoPlay called');
FW.log('this.vastPlayer.readyState - ' + this.vastPlayer.readyState);
FW.log('this.contentPlayer.readyState - ' + this.contentPlayer.readyState);
}

if (this.vastPlayer.readyState > 3 || this.contentPlayer.readyState > 3) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can either player be undefined?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@solitaa what about this one?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested few scenarios, like when vast is broken or video is unavailable, rmp works fine and no issue with players, but I agree that it will be more accurate to add checks.

this.play();
}
else {
this.vastPlayer.addEventListener('canplaythrough', () => {
if (DEBUG) {
FW.log('---- canplaythrough fired for vastPlayer, readyState - ' + this.vastPlayer.readyState);
}
this.play();
});
this.contentPlayer.addEventListener('canplaythrough', () => {
if (DEBUG) {
FW.log('---- canplaythrough fired for contentPlayer, readyState - ' + this.contentPlayer.readyState);
}
this.play();
});
}
};
/* module:begins */
})();
/* module:ends */
Expand Down
27 changes: 27 additions & 0 deletions js/src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,4 +545,31 @@ RmpVast.prototype.loadAds = function (vastUrl, isUrl = true) {
isUrl ? _makeAjaxRequest.call(this, vastUrl) : _parseXml.call(this, vastUrl);
};

RmpVast.prototype.pnVideoPlay = function () {
this.manualPlay = true;

if (DEBUG) {
FW.log('---- pnVideoPlay called');
FW.log('this.vastPlayer.readyState - ' + this.vastPlayer.readyState);
FW.log('this.contentPlayer.readyState - ' + this.contentPlayer.readyState);
}

if (this.vastPlayer.readyState > 3 || this.contentPlayer.readyState > 3) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

this.play();
} else {
this.vastPlayer.addEventListener('canplaythrough', () => {
if (DEBUG) {
FW.log('---- canplaythrough fired for vastPlayer, readyState - ' + this.vastPlayer.readyState);
}
this.play();
});
this.contentPlayer.addEventListener('canplaythrough', () => {
if (DEBUG) {
FW.log('---- canplaythrough fired for contentPlayer, readyState - ' + this.contentPlayer.readyState);
}
this.play();
});
}
};

export default RmpVast;
5 changes: 4 additions & 1 deletion js/src/players/content-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import HELPERS from '../utils/helpers';
const CONTENTPLAYER = {};

CONTENTPLAYER.play = function (firstContentPlayerPlayRequest) {
if (this.contentPlayer && this.contentPlayer.paused) {
if (DEBUG) {
FW.log('---- CONTENTPLAYER.play - autoplay - ' + this.autoplay + ', manualPlay - ' + this.manualPlay);
}
if (this.contentPlayer && this.contentPlayer.paused && (this.autoplay || this.manualPlay)) {
HELPERS.playPromise.call(this, 'content', firstContentPlayerPlayRequest);
}
};
Expand Down
5 changes: 4 additions & 1 deletion js/src/players/vast-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,10 @@ VASTPLAYER.getMute = function () {
};

VASTPLAYER.play = function (firstVastPlayerPlayRequest) {
if (this.vastPlayer && this.vastPlayer.paused) {
if (DEBUG) {
FW.log('---- VASTPLAYER.play - autoplay - ' + this.autoplay + ', manualPlay - ' + this.manualPlay);
}
if (this.vastPlayer && this.vastPlayer.paused && (this.autoplay || this.manualPlay)) {
HELPERS.playPromise.call(this, 'vast', firstVastPlayerPlayRequest);
}
};
Expand Down