Big performance improvement! Added Caddyfile, using Caddy's file server to serve large files instead of PHP

This commit is contained in:
markmental 2026-03-02 16:58:47 -05:00
commit 10502157a3
4 changed files with 73 additions and 3 deletions

View file

@ -475,6 +475,17 @@ function navigateToPlayback(path) {
window.location.href = `index.php?${params.toString()}`;
}
function buildMediaStreamUrl(path) {
const normalized = String(path || '').replace(/\\/g, '/');
const encodedPath = normalized
.split('/')
.filter(Boolean)
.map(part => encodeURIComponent(part))
.join('/');
return `/media/${encodedPath}`;
}
function playFile(path, name) {
const container = $('playerContainer');
const ext = path.toLowerCase().split('.').pop();
@ -483,7 +494,7 @@ function playFile(path, name) {
const media = document.createElement(isVideo ? 'video' : 'audio');
media.controls = true;
media.autoplay = true;
media.src = `serve_media.php?file=${encodeURIComponent(path)}`;
media.src = buildMediaStreamUrl(path);
media.addEventListener('error', () => {
container.innerHTML = `