|
|
|
@ -129,8 +129,6 @@ function drawDebugText() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Function to extract filename from full path
|
|
|
|
// Function to extract filename from full path
|
|
|
|
function getFilename(src) { |
|
|
|
function getFilename(src) { |
|
|
|
const parts = src.split('/'); |
|
|
|
const parts = src.split('/'); |
|
|
|
@ -160,24 +158,21 @@ window.addEventListener("resize", updateCanvasSize); |
|
|
|
updateCanvasSize() |
|
|
|
updateCanvasSize() |
|
|
|
|
|
|
|
|
|
|
|
function selectRandomVideo(videoElement) { |
|
|
|
function selectRandomVideo(videoElement) { |
|
|
|
console.log("selectRandomVideo",videoElement) |
|
|
|
|
|
|
|
fetch("/api/videos") |
|
|
|
fetch("/api/videos") |
|
|
|
.then((response) => response.json()) |
|
|
|
.then(response => response.json()) |
|
|
|
.then((videoFiles) => { |
|
|
|
.then(videoFiles => { |
|
|
|
const otherVideo = videos.find((video) => video !== videoElement); |
|
|
|
const currentSrc = videoElement.src; |
|
|
|
|
|
|
|
const filteredVideos = videoFiles.filter(video => video.src !== currentSrc); |
|
|
|
let randomVideo; |
|
|
|
if (filteredVideos.length > 0) { |
|
|
|
do { |
|
|
|
const randomIndex = Math.floor(Math.random() * filteredVideos.length); |
|
|
|
const randomIndex = Math.floor(Math.random() * videoFiles.length); |
|
|
|
const randomVideo = filteredVideos[randomIndex]; |
|
|
|
randomVideo = videoFiles[randomIndex]; |
|
|
|
|
|
|
|
} while (randomVideo === otherVideo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
videoElement.src = randomVideo.src; |
|
|
|
videoElement.src = randomVideo.src; |
|
|
|
videoElement.play(); |
|
|
|
} else { |
|
|
|
return videoElement |
|
|
|
console.log("No other videos available."); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.catch(error => console.error("Error fetching videos:", error)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
document.addEventListener('keydown', function(event) { |
|
|
|
document.addEventListener('keydown', function(event) { |
|
|
|
console.log('keyDown',event) |
|
|
|
console.log('keyDown',event) |
|
|
|
|