(inacurrate) seamless looping
ideally this should use something like the audio context api, for now this is fine
This commit is contained in:
parent
504f7ab0e7
commit
c046e4850a
1 changed files with 16 additions and 1 deletions
17
index.html
17
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');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue