diff --git a/editor.py b/editor.py index 3aa587d..adae4ec 100644 --- a/editor.py +++ b/editor.py @@ -434,7 +434,16 @@ audio.addEventListener('timeupdate', () => { renderPlayhead(); if (audio.currentTime >= end && !audio.paused) audio.pause(); }); +audio.addEventListener('loadedmetadata', renderPlayhead); +audio.addEventListener('play', renderPlayhead); +audio.addEventListener('pause', renderPlayhead); audio.addEventListener('seeking', renderPlayhead); + +function animatePlayhead() { + renderPlayhead(); + if (!audio.paused) requestAnimationFrame(animatePlayhead); +} +audio.addEventListener('play', () => requestAnimationFrame(animatePlayhead)); function jump(sec) { audio.currentTime=Math.max(0,Math.min(duration,audio.currentTime+sec)); renderPlayhead(); } function playFromStart() { audio.currentTime=start; renderPlayhead(); audio.play(); } function playSelection() { audio.currentTime=start; renderPlayhead(); audio.play(); } @@ -588,33 +597,37 @@ async function renameFile(kind, filename) { const newName = entered.trim(); if (!newName || newName === current) return; - const response = await fetch('/api/file', { - method: 'POST', - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({action: 'rename', kind, filename, new_filename: newName}) - }); - const result = await response.json(); - if (!result.success) { - alert(result.error || 'Umbenennen fehlgeschlagen.'); - return; + try { + const response = await fetch('/api/file', { + method: 'POST', + headers: {'Content-Type': 'application/json'}, + body: JSON.stringify({action: 'rename', kind, filename, new_filename: newName}) + }); + const result = await response.json(); + if (!response.ok || !result.success) throw new Error(result.error || `HTTP ${response.status}`); + location.reload(); + } catch (error) { + console.error('Umbenennen fehlgeschlagen:', error); + alert('Umbenennen fehlgeschlagen: ' + error.message); } - location.reload(); } async function deleteFile(kind, filename) { if (!confirm('Datei wirklich löschen?\n\n' + filename)) return; - const response = await fetch('/api/file', { - method: 'POST', - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({action: 'delete', kind, filename}) - }); - const result = await response.json(); - if (!result.success) { - alert(result.error || 'Löschen fehlgeschlagen.'); - return; + try { + const response = await fetch('/api/file', { + method: 'POST', + headers: {'Content-Type': 'application/json'}, + body: JSON.stringify({action: 'delete', kind, filename}) + }); + const result = await response.json(); + if (!response.ok || !result.success) throw new Error(result.error || `HTTP ${response.status}`); + location.reload(); + } catch (error) { + console.error('Löschen fehlgeschlagen:', error); + alert('Löschen fehlgeschlagen: ' + error.message); } - location.reload(); }