aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/plyr.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2018-03-10 23:32:15 +1100
committerGitHub <noreply@github.com>2018-03-10 23:32:15 +1100
commiteebae4a227f2ac5e60716fe74ab3a934a792c38e (patch)
tree1fc758718f878cbbea3d8c76d3befdea3d812856 /src/js/plyr.js
parent6f061621ad64eefd0e831b8e1372ca665a130d5c (diff)
parent6a2ca534d219233b20941bfc987f7a4a488502c7 (diff)
downloadplyr-eebae4a227f2ac5e60716fe74ab3a934a792c38e.tar.lz
plyr-eebae4a227f2ac5e60716fe74ab3a934a792c38e.tar.xz
plyr-eebae4a227f2ac5e60716fe74ab3a934a792c38e.zip
Merge pull request #802 from gehaktmolen/ad-hotfixes
Advertisement couldnt be loaded when creative dimensions do not align after resizing
Diffstat (limited to 'src/js/plyr.js')
-rw-r--r--src/js/plyr.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js
index 7f8ad18c..04913046 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -309,13 +309,15 @@ class Plyr {
* Play the media, or play the advertisement (if they are not blocked)
*/
play() {
- // TODO: Always return a promise?
- if (this.ads.enabled && !this.ads.initialized && !this.ads.blocked) {
- this.ads.play();
- return null;
+ // Return the promise (for HTML5)
+ if (this.ads.enabled && !this.ads.initialized) {
+ return this.ads.managerPromise.then(() => {
+ this.ads.play();
+ }).catch(() => {
+ this.media.play();
+ });
}
- // Return the promise (for HTML5)
return this.media.play();
}