atempt fix timeline in hardware
This commit is contained in:
parent
a5930cb506
commit
ffc5f67bde
@ -224,6 +224,7 @@ def updatefileindex():
|
||||
last_log_time = start_time
|
||||
next_log_count = PROGRESS_EVERY_FILES
|
||||
scanned_count = 0
|
||||
last_log_count = 0
|
||||
|
||||
extract_structure = hf.extract_structure_from_string
|
||||
extract_date = hf.extract_date_from_string
|
||||
@ -274,17 +275,20 @@ def updatefileindex():
|
||||
now = monotonic()
|
||||
if scanned_count >= next_log_count or (now - last_log_time) >= PROGRESS_EVERY_SECS:
|
||||
elapsed = max(now - start_time, 0.0001)
|
||||
rate = scanned_count / elapsed
|
||||
log(f" progress: {scanned_count} files, {scan_stats['dirs']} dirs, {rate:.1f} files/s")
|
||||
window_elapsed = max(now - last_log_time, 0.0001)
|
||||
window_count = scanned_count - last_log_count
|
||||
window_rate = window_count / window_elapsed
|
||||
log(f" progress: {scanned_count} files, {scan_stats['dirs']} dirs, {window_rate:.1f} files/s")
|
||||
last_log_time = now
|
||||
last_log_count = scanned_count
|
||||
next_log_count = scanned_count + PROGRESS_EVERY_FILES
|
||||
|
||||
# Progress indicator
|
||||
dir_count = scan_stats["dirs"]
|
||||
file_count = scanned_count
|
||||
elapsed = max(monotonic() - start_time, 0.0001)
|
||||
rate = file_count / elapsed
|
||||
log(f"Scan summary for '{foldername}': {dir_count} dirs, {file_count} files, {rate:.1f} files/s")
|
||||
avg_rate = file_count / elapsed
|
||||
log(f"Scan summary for '{foldername}': {dir_count} dirs, {file_count} files, {avg_rate:.1f} files/s avg")
|
||||
if scan_stats["skipped_dirs"]:
|
||||
log(f" skipped dirs: {scan_stats['skipped_dirs']}")
|
||||
if scan_stats["perm_errors"]:
|
||||
|
||||
@ -23,6 +23,7 @@ class SimpleAudioPlayer {
|
||||
this.isSeeking = false;
|
||||
this.rafId = null;
|
||||
this.abortCtrl = null;
|
||||
this._hasMetadata = false;
|
||||
|
||||
// Pre-compute icons once
|
||||
const fill = getComputedStyle(document.documentElement)
|
||||
@ -58,6 +59,7 @@ class SimpleAudioPlayer {
|
||||
*/
|
||||
_pushPositionState(force = false) {
|
||||
if (!navigator.mediaSession?.setPositionState) return;
|
||||
if (!this._hasMetadata) return;
|
||||
|
||||
const duration = this.audio.duration;
|
||||
const position = this.audio.currentTime;
|
||||
@ -91,7 +93,17 @@ class SimpleAudioPlayer {
|
||||
this.minBtn.addEventListener('click', () => this.toggleCollapse());
|
||||
}
|
||||
|
||||
this.audio.addEventListener('loadstart', () => {
|
||||
this._hasMetadata = false;
|
||||
this.timeline.min = 0;
|
||||
this.timeline.max = 0;
|
||||
this.timeline.value = 0;
|
||||
this.timeline.style.backgroundSize = '0% 100%';
|
||||
this.timeInfo.textContent = '00:00 / --:--';
|
||||
});
|
||||
|
||||
this.audio.addEventListener('loadedmetadata', () => {
|
||||
this._hasMetadata = true;
|
||||
this.timeline.min = 0;
|
||||
this.timeline.max = this.audio.duration;
|
||||
this.timeline.value = 0;
|
||||
@ -150,7 +162,7 @@ class SimpleAudioPlayer {
|
||||
}
|
||||
|
||||
updateTimeline() {
|
||||
if (!this.audio.duration || this.isSeeking) return;
|
||||
if (!this._hasMetadata || !this.audio.duration || this.isSeeking) return;
|
||||
|
||||
// 1) Move the thumb
|
||||
this.timeline.value = this.audio.currentTime;
|
||||
@ -208,8 +220,12 @@ class SimpleAudioPlayer {
|
||||
const urlWithReq = `/media/${relUrl}${relUrl.includes('?') ? '&' : '?'}req=${encodeURIComponent(requestId)}`;
|
||||
|
||||
// Reset any residual state from the previous track before we fetch the new one
|
||||
this._hasMetadata = false;
|
||||
this.audio.pause();
|
||||
this.audio.currentTime = 0;
|
||||
this.audio.removeAttribute('src');
|
||||
this.audio.load();
|
||||
this.timeline.min = 0;
|
||||
this.timeline.max = 0;
|
||||
this.timeline.value = 0;
|
||||
this.timeline.style.backgroundSize = '0% 100%';
|
||||
this.timeInfo.textContent = '00:00 / --:--';
|
||||
@ -231,6 +247,7 @@ class SimpleAudioPlayer {
|
||||
if (!head.ok) throw new Error(`Status ${head.status}`);
|
||||
|
||||
this.audio.src = urlWithReq;
|
||||
this.audio.load();
|
||||
await this.audio.play();
|
||||
|
||||
// Full breadcrumb
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user