(inacurrate) seamless looping

ideally this should use something like the audio context api, for now this is fine
This commit is contained in:
torcado194 2022-09-19 16:28:05 -04:00
parent 504f7ab0e7
commit c046e4850a

View file

@ -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');