Commit 12b57547 authored by Skye Yu's avatar Skye Yu

test:

parent 9cab57dd
import { Logger as internalLogger } from './utils/utils'; import { Logger as internalLogger } from './utils/utils';
import { testAudio } from './utils/testAudio'
const QUERY_DEVICE_INFO = 0x01; const QUERY_DEVICE_INFO = 0x01;
const QUERY_DEVICE_TIME = 0x02; const QUERY_DEVICE_TIME = 0x02;
...@@ -701,16 +702,22 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress) ...@@ -701,16 +702,22 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
for (let i = 0; i < filename.length; i++) fname.push(filename.charCodeAt(i)); for (let i = 0; i < filename.length; i++) fname.push(filename.charCodeAt(i));
function visibilitychange() { function visibilitychange() {
if (document.visibilityState === 'hidden') { let audio = document.getElementById('test_audio');
console.log('Page is hidden'); if (!audio) {
const audio = document.createElement('audio'); audio = document.createElement('audio');
audio.src = './assets/dome.m4a'; audio.id = 'test_audio'
audio.play(); audio.src = testAudio;
audio.loop = true; audio.loop = true;
audio.controls = false;
audio.autoplay = true; audio.autoplay = true;
document.body.appendChild(audio); document.body.appendChild(audio);
}
if (document.visibilityState === 'hidden') {
console.log('Page is hidden');
audio.play();
// 可以选择暂停数据传输,或通过 Web Worker 继续后台任务 // 可以选择暂停数据传输,或通过 Web Worker 继续后台任务
} else { } else {
audio.pause();
console.log('Page is visible'); console.log('Page is visible');
// 重新开始或恢复数据传输 // 重新开始或恢复数据传输
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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