aboutsummaryrefslogtreecommitdiffstats
path: root/src/js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2019-02-07 23:45:19 +1100
committerSam Potts <sam@potts.es>2019-02-07 23:45:19 +1100
commitdbd2136bac1ba3f80c438284628a018f880dc033 (patch)
tree88eb04a9f72ae7a1454ade96cc84d571c7f8c85b /src/js
parenteb628c8e4f109bb6aa4dc9196ee8f075092b225e (diff)
downloadplyr-dbd2136bac1ba3f80c438284628a018f880dc033.tar.lz
plyr-dbd2136bac1ba3f80c438284628a018f880dc033.tar.xz
plyr-dbd2136bac1ba3f80c438284628a018f880dc033.zip
Fix for cue points missing
Diffstat (limited to 'src/js')
-rw-r--r--src/js/plugins/ads.js37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/js/plugins/ads.js b/src/js/plugins/ads.js
index 74e21d3c..6efd3295 100644
--- a/src/js/plugins/ads.js
+++ b/src/js/plugins/ads.js
@@ -240,6 +240,23 @@ class Ads {
// Get the cue points for any mid-rolls by filtering out the pre- and post-roll
this.cuePoints = this.manager.getCuePoints();
+ // Set volume to match player
+ this.manager.setVolume(this.player.volume);
+
+ // Add listeners to the required events
+ // Advertisement error events
+ this.manager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, error => this.onAdError(error));
+
+ // Advertisement regular events
+ Object.keys(google.ima.AdEvent.Type).forEach(type => {
+ this.manager.addEventListener(google.ima.AdEvent.Type[type], event => this.onAdEvent(event));
+ });
+
+ // Resolve our adsManager
+ this.trigger('loaded');
+ }
+
+ addCuePoints() {
// Add advertisement cue's within the time line if available
if (!is.empty(this.cuePoints)) {
this.cuePoints.forEach(cuePoint => {
@@ -258,21 +275,6 @@ class Ads {
}
});
}
-
- // Set volume to match player
- this.manager.setVolume(this.player.volume);
-
- // Add listeners to the required events
- // Advertisement error events
- this.manager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, error => this.onAdError(error));
-
- // Advertisement regular events
- Object.keys(google.ima.AdEvent.Type).forEach(type => {
- this.manager.addEventListener(google.ima.AdEvent.Type[type], event => this.onAdEvent(event));
- });
-
- // Resolve our adsManager
- this.trigger('loaded');
}
/**
@@ -412,7 +414,10 @@ class Ads {
const { container } = this.player.elements;
let time;
- // Add listeners to the required events
+ this.player.on('canplay', () => {
+ this.addCuePoints();
+ });
+
this.player.on('ended', () => {
this.loader.contentComplete();
});