Commit 10521084 authored by Skye Yu's avatar Skye Yu

fix: audio file download interrupted

parent a1fb1c1f
......@@ -709,16 +709,15 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
audio.loop = true;
audio.controls = false;
audio.autoplay = true;
audio.muted = true;
document.body.appendChild(audio);
}
if (document.visibilityState === 'hidden') {
console.log('Page is hidden');
audio.play();
// 可以选择暂停数据传输,或通过 Web Worker 继续后台任务
} else {
audio.pause();
console.log('Page is visible');
// 重新开始或恢复数据传输
}
}
......@@ -730,12 +729,12 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
flen += msg.body.length || msg.body.byteLength;
ondata(msg.body);
if (flen >= length) {
// document.removeEventListener('visibilitychange', visibilitychange);
document.removeEventListener('visibilitychange', visibilitychange);
// return OK indicates all file blocks received
return 'OK';
}
} else {
// document.removeEventListener('visibilitychange', visibilitychange);
document.removeEventListener('visibilitychange', visibilitychange);
ondata('fail');
}
};
......
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