From 55bc1811266cc3b599a2fbd52897d6ea6ef5ed3d Mon Sep 17 00:00:00 2001
From: Troels Ugilt Jensen <tujensen@gmail.com>
Date: Mon, 29 Oct 2018 09:16:45 +0100
Subject: [PATCH] SUPPORT-1800: Fixed try/catch to catch initialization errors

---
 CHANGELOG.md                                      |  4 ++++
 .../templates/vimeo/slides/itk-vimeo/itk-vimeo.js | 15 +++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index cf90e3e..533991c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # itk-os2display/vimeo-bundle CHANGELOG
 
+## 1.0.5
+
+* Fixed try/catch to catch initialization errors as well.
+
 ## 1.0.4
 
 * Changed video ID input field to be number field.
diff --git a/Resources/public/templates/vimeo/slides/itk-vimeo/itk-vimeo.js b/Resources/public/templates/vimeo/slides/itk-vimeo/itk-vimeo.js
index 606d44d..94856c0 100644
--- a/Resources/public/templates/vimeo/slides/itk-vimeo/itk-vimeo.js
+++ b/Resources/public/templates/vimeo/slides/itk-vimeo/itk-vimeo.js
@@ -46,12 +46,12 @@ if (!window.slideFunctions['itk-vimeo']) {
 
                 var element = document.querySelector('.js-itk-vimeo--player-' + slide.uniqueId);
 
-                // Initialize vimeo player.
-                if (!slide.player) {
-                    slide.player = new Vimeo.Player(element, options);
-                }
-
                 try {
+                    // Initialize vimeo player.
+                    if (!slide.player) {
+                        slide.player = new Vimeo.Player(element, options);
+                    }
+
                     var player = slide.player;
 
                     // Unregister previous event listeners.
@@ -88,7 +88,10 @@ if (!window.slideFunctions['itk-vimeo']) {
                     });
                 }
                 catch (err) {
-                    region.nextSlide();
+                    region.itkLog.info("Error running vimeo video, continuing");
+                    region.$timeout((function (region) {
+                        region.nextSlide();
+                    })(region), 1000);
                 }
             }, region.fadeTime);
         }