fix nan duration

This commit is contained in:
JerryXiao 2022-07-10 00:31:32 +08:00
parent 838f11aa77
commit edbc474b9a
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5

View file

@ -1028,6 +1028,7 @@ class Player extends Component {
DOM.subtitle.textContent = subtitle(data, {duration:false});
let duration = Number(data["duration"]);
duration = Number.isNaN(duration) ? 1 : duration;
DOM.duration.textContent = time(duration);
DOM.progress.max = duration;
DOM.progress.disabled = false;
@ -1073,6 +1074,7 @@ class Player extends Component {
}
DOM.progress.value = elapsed;
if (elapsed >= DOM.progress.max) { DOM.progress.max = elapsed; DOM.duration.textContent = time(elapsed); }
DOM.elapsed.textContent = time(elapsed);
this._app.style.setProperty("--progress", DOM.progress.value/DOM.progress.max);
}