下載並管理附件,支持斷點續傳,支持打開,刪除和清空附件。
插件代碼:ImagDownloader
支持平臺:Android,iOS
方法:
下載附件
示例代碼
var downloader =$phone.plugin('ImagDownloader');
downloader.download(url);
var downloader =$phone.plugin('ImagDownloader');
downloader.openDirect(url);
效果圖
管理附件
示例代碼
var downloader =$phone.plugin('ImagDownloader');
downloader.openDownloader();
效果圖
清除附件
示例代碼
var downloader =$phone.plugin('ImagDownloader');
downloader.clearAttachments();
監聽下載回調並播放音樂
示例代碼
檢測是否下載
示例代碼
function isDownload(){
alert(downloader.isDownload("http://oif2c5wmr.bkt.clouddn.com/%E6%B8%A9%E6%9F%94-%E4%BA%91.mp3"));
}
自定義下載參數
示例代碼
downloader.download('http://oif2c5wmr.bkt.clouddn.com/%E6%B8%A9%E6%9F%94-%E4%BA%91.mp3',{
isShowNotification: false,
fileName: "溫柔.mp3",
onProgress: function(downloadInfo){
hint("下載進度:" + downloadInfo.progress + " 已下載:"+downloadInfo.downloadLength+"總大小:"+downloadInfo.totalLength+"下載速度:" +downloadInfo.speed);
},
onSuccess: function(path) {
alert("onSuccess" + path);
},
onError: function(path) {
alert("onError" + path);
}
});}
閱讀更多 愛碼哥 的文章