plus.downloader.createDownload pause android手机ANR(手机小米3),iphones无问题:
function createDownload() {
mDownloadTask = plus.downloader.createDownload(app.getIMGURL() + mDownloadUrl, {
filename: mDownloadUrl + '.mp4'
}, function ( d, status ) {
console.log("6666");
if ( status == 200 ) {
console.log( "Download success: " + d.filename );
if (mui.os.android) {
plus.runtime.openFile('_downloads/' + mDownloadUrl + '.mp4');
} else if (mui.os.ios){
var path = plus.io.convertLocalFileSystemURL( '_downloads/' + mDownloadUrl + '.mp4' );
ui.physical.video.innerHTML = '<video style="width:100%; height:160px;" controls="controls" src="' + path + '"></video>';
}
} else {
console.log( "Download failed: " + status );
mPerUIID.innerHTML = '下载失败';
}
mISDownloading = false;
mDownloadTask =null;
});
mDownloadTask.addEventListener( "statechanged", onStateChanged, false );
mDownloadTask.start();
}
function onClickDownload() {
mPerUIID = document.getElementById('download_per');
mDownloadButton = document.getElementById('download_button');
console.log("111");
console.log(mISDownloading);
if (true == mISDownloading && null != mDownloadTask) {
console.log("222");
mDownloadButton.style.backgroundImage = "url('../../images/x6.png')";
mDownloadTask.pause();
mISDownloading = false;
} else {
console.log("333");
mISDownloading= true;
mDownloadButton.style.backgroundImage = "url('../../images/a6w.png')";
if(mDownloadTask) {
console.log("444");
mDownloadTask.resume();
} else {
console.log("555");
createDownload();
}
}
}
0 个回复