aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/plugins/ads.js
diff options
context:
space:
mode:
authorArthur Hulsman <a.hulsman@orangegames.com>2018-03-06 17:27:59 +0100
committerArthur Hulsman <a.hulsman@orangegames.com>2018-03-06 17:27:59 +0100
commite90a603d57836f6b8962a661b4668fd81c9b72a4 (patch)
tree3bb95ed46039770106139ea2dbf1e7957a6f1b31 /src/js/plugins/ads.js
parent6f061621ad64eefd0e831b8e1372ca665a130d5c (diff)
downloadplyr-e90a603d57836f6b8962a661b4668fd81c9b72a4.tar.lz
plyr-e90a603d57836f6b8962a661b4668fd81c9b72a4.tar.xz
plyr-e90a603d57836f6b8962a661b4668fd81c9b72a4.zip
Removed a double this.enabled variable and updated a comment in ads.js. Also made sure the adsmanager promise also can fail, so we can use it to wait for getting the advertisement ready when someone clicks the play button. Otherwise there it can look glitchy when the actual video starts playing and the video ad plays a few seconds later because the vast tag was slow to retrieve. Also fixed a typo.
Diffstat (limited to 'src/js/plugins/ads.js')
-rw-r--r--src/js/plugins/ads.js13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/js/plugins/ads.js b/src/js/plugins/ads.js
index 0faf0f2f..9318e01d 100644
--- a/src/js/plugins/ads.js
+++ b/src/js/plugins/ads.js
@@ -36,9 +36,8 @@ class Ads {
this.playing = false;
this.initialized = false;
this.blocked = false;
- this.enabled = utils.is.url(player.config.ads.tag);
- // Check if a tag URL is provided.
+ // Check if ads are enabled.
if (!this.enabled) {
return;
}
@@ -83,14 +82,12 @@ class Ads {
// thing doesn't resolve within our set time; we bail
this.startSafetyTimer(12000, 'ready()');
- // Setup a simple promise to resolve if the IMA loader is ready
- this.loaderPromise = new Promise(resolve => {
- this.on('ADS_LOADER_LOADED', () => resolve());
- });
-
// Setup a promise to resolve if the IMA manager is ready
- this.managerPromise = new Promise(resolve => {
+ this.managerPromise = new Promise((resolve, reject) => {
+ // The ad is pre-loaded and ready
this.on('ADS_MANAGER_LOADED', () => resolve());
+ // Ads failed
+ this.on('ERROR', () => reject());
});
// Clear the safety timer