diff --git a/pikaraoke/app.py b/pikaraoke/app.py index 38a7096..c95ae2e 100644 --- a/pikaraoke/app.py +++ b/pikaraoke/app.py @@ -548,6 +548,7 @@ def splash(): hide_url=k.hide_url, hide_overlay=k.hide_overlay, screensaver_timeout=k.screensaver_timeout, + show_end_time=k.buffer_fully_before_playback, ) diff --git a/pikaraoke/templates/splash.html b/pikaraoke/templates/splash.html index dc290ec..41b343b 100644 --- a/pikaraoke/templates/splash.html +++ b/pikaraoke/templates/splash.html @@ -13,6 +13,18 @@ video.readyState > 2 ); + function formatTime(seconds) { + if (isNaN(seconds)) { + return "00:00"; + } + const totalSeconds = Math.floor(seconds); + const minutes = Math.floor((totalSeconds % 3600) / 60); + const secs = totalSeconds % 60; + const formattedMinutes = String(minutes).padStart(2, "0"); + const formattedSeconds = String(secs).padStart(2, "0"); + return `${formattedMinutes}:${formattedSeconds}`; + } + const isFirefox = typeof InstallTrigger !== "undefined"; const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); @@ -213,14 +225,20 @@ }; //Video status events for communicating state back to server - $("#video")[0].addEventListener("play", () => { + const video = $("#video")[0]; + video.addEventListener("play", () => { $("#video-container").show(); //Report song start after a slight delay to allow video to load setTimeout(() => $.get('{{ url_for("start_song") }}'), 1200); }); - $("#video")[0].addEventListener("ended", () => { + video.addEventListener("ended", () => { endSong(); }); + video.addEventListener("timeupdate", (e) => { + $("#current").text(formatTime(video.currentTime)); + $("#duration").text(formatTime(video.duration)); + }); + $("#video source")[0].addEventListener("error", (e) => { console.log("Error while playing video."); console.log(e); @@ -283,7 +301,10 @@ style="margin-bottom: 5px" >