(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 => {
|
playerEl.addEventListener('timeupdate', e => {
|
||||||
|
let buffer = 0.18;
|
||||||
if(!scrubberDragged){
|
if(!scrubberDragged){
|
||||||
if(currentEntry.duration && !currentEntry.needsDuration){
|
if(currentEntry.duration && !currentEntry.needsDuration){
|
||||||
if(currentEntry.started){
|
if(currentEntry.started){
|
||||||
let time = e.target.currentTime;
|
let time = e.target.currentTime;
|
||||||
if(time > currentEntry.previewEnd - currentEntry.audioStart){
|
if(time > (currentEntry.previewEnd - currentEntry.audioStart) - buffer){
|
||||||
nextTrack(false);
|
nextTrack(false);
|
||||||
} else {
|
} else {
|
||||||
let t = time / currentEntry.duration;
|
let t = time / currentEntry.duration;
|
||||||
|
@ -1203,6 +1204,11 @@
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
let time = e.target.currentTime;
|
||||||
|
if(time > e.target.duration - buffer){
|
||||||
|
nextTrack(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1543,6 +1549,15 @@
|
||||||
if(entry.locked){
|
if(entry.locked){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(entry === currentEntry){
|
||||||
|
if(entry.type === 'video'){
|
||||||
|
mediaVideoEl.currentTime = 0;
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
playerEl.currentTime = 0;
|
||||||
|
playerEl.play();
|
||||||
|
return;
|
||||||
|
}
|
||||||
currentEntry = entry;
|
currentEntry = entry;
|
||||||
media.forEach(thisEntry => {
|
media.forEach(thisEntry => {
|
||||||
thisEntry.trackEl.classList.remove('active');
|
thisEntry.trackEl.classList.remove('active');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue