From c046e4850a97f569cf5b41fa6e42f1f243a746a4 Mon Sep 17 00:00:00 2001 From: torcado194 Date: Mon, 19 Sep 2022 16:28:05 -0400 Subject: [PATCH] (inacurrate) seamless looping ideally this should use something like the audio context api, for now this is fine --- index.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 7af3adb..32659a6 100644 --- a/index.html +++ b/index.html @@ -1189,11 +1189,12 @@ } }); playerEl.addEventListener('timeupdate', e => { + let buffer = 0.18; if(!scrubberDragged){ if(currentEntry.duration && !currentEntry.needsDuration){ if(currentEntry.started){ let time = e.target.currentTime; - if(time > currentEntry.previewEnd - currentEntry.audioStart){ + if(time > (currentEntry.previewEnd - currentEntry.audioStart) - buffer){ nextTrack(false); } else { let t = time / currentEntry.duration; @@ -1203,6 +1204,11 @@ } else { } + } else { + let time = e.target.currentTime; + if(time > e.target.duration - buffer){ + nextTrack(false); + } } } }); @@ -1543,6 +1549,15 @@ if(entry.locked){ return; } + if(entry === currentEntry){ + if(entry.type === 'video'){ + mediaVideoEl.currentTime = 0; + } else { + } + playerEl.currentTime = 0; + playerEl.play(); + return; + } currentEntry = entry; media.forEach(thisEntry => { thisEntry.trackEl.classList.remove('active');