only update player UI when its visible

This commit is contained in:
ThaUnknown 2020-11-25 13:26:07 +01:00
parent e3c82861b4
commit 3b37e74e23

View file

@ -97,10 +97,12 @@ async function buildVideo(file, nowPlaying) {
// file.on("done", () => { console.log("test") }) // this currently wont work, idk how to remove old listeners
onProgress = function () {
if (document.location.hash == "#player" && typeof video !== 'undefined') {
player.style.setProperty("--download", file.progress * 100 + "%");
peers.textContent = client.torrents[0].numPeers
downSpeed.textContent = prettyBytes(client.torrents[0].downloadSpeed) + '/s'
upSpeed.textContent = prettyBytes(client.torrents[0].uploadSpeed) + '/s'
if (!player.classList.contains('immersed')) {
player.style.setProperty("--download", file.progress * 100 + "%");
peers.textContent = client.torrents[0].numPeers
downSpeed.textContent = prettyBytes(client.torrents[0].downloadSpeed) + '/s'
upSpeed.textContent = prettyBytes(client.torrents[0].uploadSpeed) + '/s'
}
if (file.progress == 1 && !playerData.done) {
playerData.done = 1
halfmoon.initStickyAlert({
@ -198,7 +200,7 @@ async function dragBarStart() {
let currentTime = 0;
function updateBar(progressPercent) {
if (document.location.hash == "#player") {
if (document.location.hash == "#player" && !player.classList.contains('immersed')) {
progress.style.setProperty("--progress", progressPercent + "%");
thumb.style.setProperty("--progress", progressPercent + "%");
if (typeof video !== 'undefined') {