Skip to content

Commit

Permalink
Merge pull request googleads#310 from shawnbuso/playlist_fix
Browse files Browse the repository at this point in the history
Fixed issue googleads#300.
  • Loading branch information
shawnbuso authored Dec 1, 2016
2 parents 55e33b2 + 11f6385 commit 2933c1a
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 2933c1a

Please sign in to comment.