Refactored progress tracking to use an event. Removed a debug print.

This commit is contained in:
Erik Thuning 2022-10-27 16:09:29 +02:00
parent 1a661ac4e9
commit 2948002b63

@ -204,7 +204,6 @@
}
attributeChangedCallback(name, oldValue, newValue) {
console.log(name, oldValue, newValue);
switch(name) {
case 'play':
if(newValue === "" || newValue === null) {
@ -637,7 +636,7 @@
this.setActivePlaylistItem();
this.autoBlurControls();
this.updateProgress();
this.initProgressTracking();
}
/*
@ -677,6 +676,18 @@
this.autoBlurControls();
}
/*
* Set up progress tracking
*/
initProgressTracking() {
this._controlSource.addEventListener(
'timeupdate', (event) => {
this._elapsed.textContent = this.formatTime(
this._controlSource.currentTime);
}
);
}
/*
* Update the playlist to reflect which item is playing
*
@ -892,17 +903,6 @@
this._mainSource = newMain;
this.syncSources();
}
updateProgress() {
if(this._progressInterval != null) {
window.clearInterval(this._progressInterval)
}
this._progressInterval = window.setInterval(
() => {
this._elapsed.textContent = this.formatTime(
this._controlSource.currentTime);
}, 200);
}
}
customElements.define('multi-player', MultiPlayer);