Skip to content

Commit

Permalink
add touchstart
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdiemmen committed Jun 22, 2017
1 parent 87ef5e1 commit d05396f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/js/plyr-ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
this.adDisplayContainer = new window.google.ima.AdDisplayContainer(
this.plyr.getContainer());
this.adDisplayContainer.I.setAttribute('class', 'plyr-ads');
this.adDisplayContainer.I.addEventListener('click', function() {
this.adDisplayContainer.I.addEventListener(_getStartEvent(), function() {
this.playAds();
}.bind(this), false);
}
Expand All @@ -133,14 +133,25 @@
if ((skipTimer + 1) === 0) {
this.skipAdButton.className += ' done';
this.skipAdButton.innerHTML = this.options.skipButton.text;
this.skipAdButton.addEventListener('click', function() {
this.skipAdButton.addEventListener(_getStartEvent(), function() {
this.playVideo();
}.bind(this), false);
window.clearInterval(skipButtonTimer);
}
}.bind(this), 1000);
}

function _getStartEvent() {
// Set the correct event based on userAgent.
var startEvent = 'click';
if (navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/Android/i)) {
startEvent = 'touchstart';
}
return startEvent;
}

// Prepend child
function _prependChild(parent, element) {
return parent.insertBefore(element, parent.firstChild);
Expand Down

0 comments on commit d05396f

Please sign in to comment.