Skip to content

Commit

Permalink
Fixed issue googleads#309.
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnbuso committed Nov 17, 2016
1 parent a4c3a17 commit 11f6385
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions examples/playlist/ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var Ads = function() {
navigator.userAgent.match(/Android/i)) {
startEvent = 'touchend';
}
this.player.one(startEvent, this.bind(this, this.init));
this.player.one(startEvent, this.bind(this, this.initFromStart));

this.options = {
id: 'content_video',
Expand Down Expand Up @@ -85,12 +85,22 @@ var Ads = function() {

}

Ads.prototype.initFromStart = function() {
if (!this.initialized) {
this.init();
this.requestAdsAndPlay();
}
}

Ads.prototype.init = function() {
this.initialized = true;
this.player.ima.initializeAdDisplayContainer();
};

Ads.prototype.requestAdsAndPlay = function() {
this.player.ima.requestAds();
this.player.play();
};
}

Ads.prototype.adsManagerLoadedCallback = function() {
for (var index = 0; index < this.events.length; index++) {
Expand All @@ -113,6 +123,9 @@ Ads.prototype.onAdEvent = function(event) {
};

Ads.prototype.onPlaylistItemClick = function(event) {
if (!this.initialized) {
this.init();
}
if (!this.linearAdPlaying) {
this.player.ima.setContentWithAdTag(
this.contents[event.target.id],
Expand Down

0 comments on commit 11f6385

Please sign in to comment.