Commit 034fe900 authored by Skye Yu's avatar Skye Yu

fix: remove setInterval

parent d33ee3bb
......@@ -705,7 +705,6 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
for (let i = 0; i < filename.length; i++) fname.push(filename.charCodeAt(i));
let wakeLock = null;
let timer = null;
function visibilitychange() {
let audio = document.getElementById('test_audio');
if (!audio) {
......@@ -721,14 +720,10 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
if (document.visibilityState === 'hidden') {
console.log('Page is hidden');
audio.play();
timer = setInterval(() => {
console.log("Keeping the page alive...");
}, 1000)
} else {
audio.pause();
console.log('Page is visible');
wakeLock && wakeLock.release();
timer && clearInterval(timer)
}
}
......@@ -745,7 +740,6 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
const audio = document.getElementById('test_audio');
audio && audio.pause() && audio.remove();
wakeLock && wakeLock.release();
timer && clearInterval(timer)
console.log('Clear event and task.');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment