window.onload = function () { // Select the unmute indicator var unmuteIndicator = document.getElementById("unmute-indicator"); console.log("Unmute indicator element:", unmuteIndicator); // Ensure the button is initially hidden var button = document.getElementById("lp-pom-button-135"); button.style.display = "none"; // Access the JW Player instance var player = jwplayer(); // Show the "Unmute Your Player" indicator when the player starts muted player.on("ready", function () { console.log("Player is ready. Attempting to show unmute indicator."); player.setMute(true); // Ensure the player starts muted // Explicitly check and set display to block if (unmuteIndicator) { unmuteIndicator.style.display = "block"; console.log("Unmute indicator display set to block."); } else { console.error("Unmute indicator element not found in DOM."); } }); // Hide the "Unmute Your Player" indicator and unmute the player on click unmuteIndicator.addEventListener("click", function () { console.log("Unmute indicator clicked. Unmuting player."); player.setMute(false); // Unmute the player unmuteIndicator.style.display = "none"; // Hide the indicator }); // Monitor time updates to show the button at the specified time player.on("time", function (event) { var currentTime = event.position; // Current playback time in seconds var salesPitchTime = 867; // Time in seconds to show the button if (currentTime >= salesPitchTime) { console.log("Showing the button at:", currentTime); button.style.display = "block"; // Show the button } }); // Add error listener player.on("error", function (error) { console.error("JW Player Error:", error.message); }); // Detect Unbounce exit popup and pause/resume video let popupVisible = false; setInterval(function () { // Use a precise selector for the popup wrapper and visibility class const popup = document.querySelector(".ub-emb-iframe-wrapper.ub-emb-visible"); if ( popup && // Popup exists window.getComputedStyle(popup).display !== "none" && // Popup is displayed window.getComputedStyle(popup).visibility !== "hidden" && // Popup is visible !popupVisible ) { console.log("Unbounce popup detected. Pausing video."); player.pause(); popupVisible = true; } else if ( (!popup || // Popup doesn't exist window.getComputedStyle(popup).display === "none" || // Popup is not displayed window.getComputedStyle(popup).visibility === "hidden") && // Popup is not visible popupVisible ) { console.log("Unbounce popup closed. Resuming video."); player.play(); popupVisible = false; } }, 500); // Check every 500ms };