![爱码哥扩展插件:附件下载](http://p2.ttnews.xyz/loading.gif)
下载并管理附件,支持断点续传,支持打开,删除和清空附件。
插件代码:ImagDownloader
支持平台:Android,iOS
方法:
![爱码哥扩展插件:附件下载](http://p2.ttnews.xyz/loading.gif)
下载附件
示例代码
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);
}
});}
閱讀更多 愛碼哥 的文章