Commit 0d599743 authored by Skye Yu's avatar Skye Yu

add file download finish log

parent 5c9092bc
import { Logger as internalLogger } from './utils/utils'; import {Logger, Logger as internalLogger} from './utils/utils';
const QUERY_DEVICE_INFO = 0x01; const QUERY_DEVICE_INFO = 0x01;
const QUERY_DEVICE_TIME = 0x02; const QUERY_DEVICE_TIME = 0x02;
...@@ -723,7 +723,7 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress) ...@@ -723,7 +723,7 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
function removeAudio() { function removeAudio() {
const audio = document.getElementById('test_audio'); const audio = document.getElementById('test_audio');
audio && audio.remove(); audio && audio.pause() && audio.remove();
} }
document.addEventListener('visibilitychange', visibilitychange); document.addEventListener('visibilitychange', visibilitychange);
...@@ -735,6 +735,7 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress) ...@@ -735,6 +735,7 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
ondata(msg.body); ondata(msg.body);
if (flen >= length) { if (flen >= length) {
document.removeEventListener('visibilitychange', visibilitychange); document.removeEventListener('visibilitychange', visibilitychange);
Logger.info('file download finish.')
removeAudio(); removeAudio();
// return OK indicates all file blocks received // return OK indicates all file blocks received
return 'OK'; return 'OK';
...@@ -742,6 +743,7 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress) ...@@ -742,6 +743,7 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
} else { } else {
document.removeEventListener('visibilitychange', visibilitychange); document.removeEventListener('visibilitychange', visibilitychange);
removeAudio(); removeAudio();
Logger.info('file download fail.')
ondata('fail'); 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