|
|
|
|
@ -166,12 +166,12 @@ window.addEventListener("resize", updateCanvasSize)
|
|
|
|
|
function getSourceFiles() { |
|
|
|
|
debugLog("Getting source files") |
|
|
|
|
return fetch("/api/videos") |
|
|
|
|
.then(response => response.json()) |
|
|
|
|
.then(videoFiles => { |
|
|
|
|
debugLog("Success") |
|
|
|
|
cachedVideos = videoFiles; |
|
|
|
|
}) |
|
|
|
|
.catch(error => console.error("Error fetching videos:", error)); |
|
|
|
|
.then(response => response.json()) |
|
|
|
|
.then(videoFiles => { |
|
|
|
|
debugLog("Success") |
|
|
|
|
cachedVideos = videoFiles; |
|
|
|
|
}) |
|
|
|
|
.catch(error => console.error("Error fetching videos:", error)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function selectRandomVideo(videoElement) { |
|
|
|
|
@ -179,14 +179,14 @@ function selectRandomVideo(videoElement) {
|
|
|
|
|
const currentSrc = videoElement.src; |
|
|
|
|
const filteredVideos = cachedVideos.filter(video => video.src !== currentSrc); |
|
|
|
|
if (filteredVideos.length > 0) { |
|
|
|
|
const randomIndex = Math.floor(Math.random() * filteredVideos.length); |
|
|
|
|
const randomVideo = filteredVideos[randomIndex]; |
|
|
|
|
videoElement.src = randomVideo.src; |
|
|
|
|
const randomIndex = Math.floor(Math.random() * filteredVideos.length); |
|
|
|
|
const randomVideo = filteredVideos[randomIndex]; |
|
|
|
|
videoElement.src = randomVideo.src; |
|
|
|
|
} else { |
|
|
|
|
debugLog("No other videos available."); |
|
|
|
|
getSourceFiles().then(()=>{ |
|
|
|
|
selectRandomVideo(videoElement) |
|
|
|
|
}) |
|
|
|
|
debugLog("No other videos available."); |
|
|
|
|
getSourceFiles().then(()=>{ |
|
|
|
|
selectRandomVideo(videoElement) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
debugLog("Cache empty, doing new request") |
|
|
|
|
@ -197,17 +197,17 @@ function selectRandomVideo(videoElement) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
document.addEventListener('keydown', function(event) { |
|
|
|
|
console.log('keyDown',event) |
|
|
|
|
// Check if the pressed key is the one you want to bind
|
|
|
|
|
if (event.key === 'Enter') { |
|
|
|
|
showText = !showText |
|
|
|
|
} |
|
|
|
|
if (event.key === 'ArrowDown') { |
|
|
|
|
loadVideos(-1) |
|
|
|
|
} |
|
|
|
|
if (event.key === 'ArrowUp') { |
|
|
|
|
loadVideos(1) |
|
|
|
|
} |
|
|
|
|
console.log('keyDown',event) |
|
|
|
|
// Check if the pressed key is the one you want to bind
|
|
|
|
|
if (event.key === 'Enter') { |
|
|
|
|
showText = !showText |
|
|
|
|
} |
|
|
|
|
if (event.key === 'ArrowDown') { |
|
|
|
|
loadVideos(-1) |
|
|
|
|
} |
|
|
|
|
if (event.key === 'ArrowUp') { |
|
|
|
|
loadVideos(1) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
getSourceFiles().then(()=>{ |
|
|
|
|
|