Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
try catch around youtube to prevent errors
Browse files Browse the repository at this point in the history
Kevin Richter committed Apr 12, 2016
1 parent 998ead4 commit 4b8feed
Showing 3 changed files with 42 additions and 34 deletions.
36 changes: 20 additions & 16 deletions app/js/classes/popup.js
Original file line number Diff line number Diff line change
@@ -174,22 +174,26 @@ Popup.prototype.stopVideo = function() {
* Start the video inside the popup
*/
Popup.prototype.startVideo = function() {
switch(this.media_type) {
case "youtube":
if(
this.youtube && [
YT.PlayerState.UNSTARTED,
YT.PlayerState.PAUSED,
YT.PlayerState.CUED,
YT.PlayerState.BUFFERING
].indexOf(this.youtube.getPlayerState()) !== -1
) {
this.youtube.playVideo();
}
break;
case "video":
document.getElementById(this.video_id).play();
break;
try { // TODO fix youtube check
switch(this.media_type) {
case "youtube":
if(
this.youtube && [
YT.PlayerState.UNSTARTED,
YT.PlayerState.PAUSED,
YT.PlayerState.CUED,
YT.PlayerState.BUFFERING
].indexOf(this.youtube.getPlayerState()) !== -1
) {
this.youtube.playVideo();
}
break;
case "video":
document.getElementById(this.video_id).play();
break;
}
} catch(e) {
console.warn("YouTube wasn't ready, yet!", e);
}
};

36 changes: 20 additions & 16 deletions dist/m4n.js
Original file line number Diff line number Diff line change
@@ -1297,22 +1297,26 @@ var M4nInteractive = (function(options, container, callback) {
* Start the video inside the popup
*/
Popup.prototype.startVideo = function() {
switch (this.media_type) {
case "youtube":
if (
this.youtube && [
YT.PlayerState.UNSTARTED,
YT.PlayerState.PAUSED,
YT.PlayerState.CUED,
YT.PlayerState.BUFFERING
].indexOf(this.youtube.getPlayerState()) !== -1
) {
this.youtube.playVideo();
}
break;
case "video":
document.getElementById(this.video_id).play();
break;
try { // TODO fix youtube check
switch (this.media_type) {
case "youtube":
if (
this.youtube && [
YT.PlayerState.UNSTARTED,
YT.PlayerState.PAUSED,
YT.PlayerState.CUED,
YT.PlayerState.BUFFERING
].indexOf(this.youtube.getPlayerState()) !== -1
) {
this.youtube.playVideo();
}
break;
case "video":
document.getElementById(this.video_id).play();
break;
}
} catch (e) {
console.warn("YouTube wasn't ready, yet!", e);
}
};

4 changes: 2 additions & 2 deletions dist/m4n.min.js

Large diffs are not rendered by default.

0 comments on commit 4b8feed

Please sign in to comment.