aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/plugins/ads.js
diff options
context:
space:
mode:
authorSam Potts <me@sampotts.me>2018-01-30 09:22:14 +1100
committerSam Potts <me@sampotts.me>2018-01-30 09:22:14 +1100
commit71efbe7a927a9638204129ca7a2d52c498fa7e6e (patch)
treef0ed45d84bc0304a543bafa08216355e63e55ac8 /src/js/plugins/ads.js
parentafd695cb391535b508dc7a4301b6c2692ce2b607 (diff)
parent8f7a8940f36ab85c87a3406a378d383e58ee3d60 (diff)
downloadplyr-71efbe7a927a9638204129ca7a2d52c498fa7e6e.tar.lz
plyr-71efbe7a927a9638204129ca7a2d52c498fa7e6e.tar.xz
plyr-71efbe7a927a9638204129ca7a2d52c498fa7e6e.zip
Merge branch 'beta' into fix/ads-blocked
# Conflicts: # dist/plyr.js # dist/plyr.js.map # src/js/plugins/ads.js # src/js/plyr.js
Diffstat (limited to 'src/js/plugins/ads.js')
-rw-r--r--src/js/plugins/ads.js41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/js/plugins/ads.js b/src/js/plugins/ads.js
index 0059b963..72fd49d8 100644
--- a/src/js/plugins/ads.js
+++ b/src/js/plugins/ads.js
@@ -8,6 +8,22 @@
import utils from '../utils';
+// Build the default tag URL
+const getTagUrl = () => {
+ const params = {
+ AV_PUBLISHERID: '58c25bb0073ef448b1087ad6',
+ AV_CHANNELID: '5a0458dc28a06145e4519d21',
+ AV_URL: '127.0.0.1:3000',
+ cb: 1,
+ AV_WIDTH: 640,
+ AV_HEIGHT: 480,
+ };
+
+ const base = 'https://go.aniview.com/api/adserver6/vast/';
+
+ return `${base}?${utils.buildUrlParams(params)}`;
+};
+
class Ads {
/**
* Ads constructor.
@@ -16,6 +32,7 @@ class Ads {
*/
constructor(player) {
this.player = player;
+ this.enabled = player.config.ads.enabled;
this.playing = false;
this.initialized = false;
this.blocked = false;
@@ -28,14 +45,17 @@ class Ads {
// Check if the Google IMA3 SDK is loaded or load it ourselves
if (!utils.is.object(window.google)) {
- utils.loadScript(player.config.urls.googleIMA.api, () => {
- this.ready();
- }, () => {
-
- // Script failed to load or is blocked
- this.blocked = true;
- this.player.debug.log('Ads error: Google IMA SDK failed to load');
- });
+ utils.loadScript(
+ player.config.urls.googleIMA.api,
+ () => {
+ this.ready();
+ },
+ () => {
+ // Script failed to load or is blocked
+ this.blocked = true;
+ this.player.debug.log('Ads error: Google IMA SDK failed to load');
+ },
+ );
} else {
this.ready();
}
@@ -128,7 +148,7 @@ class Ads {
// Request video ads
const request = new google.ima.AdsRequest();
- request.adTagUrl = this.player.config.ads.tag;
+ request.adTagUrl = getTagUrl();
// Specify the linear and nonlinear slot sizes. This helps the SDK
// to select the correct creative if multiple are returned
@@ -161,7 +181,8 @@ class Ads {
const update = () => {
const time = utils.formatTime(this.manager.getRemainingTime());
- this.elements.container.setAttribute('data-badge-text', time);
+ const label = `${this.player.config.i18n.advertisment} - ${time}`;
+ this.elements.container.setAttribute('data-badge-text', label);
};
this.countdownTimer = window.setInterval(update, 100);