个人blog源码
renzifeng / zfdownload Goto Github PK
View Code? Open in Web Editor NEW断点下载,支持后台下载,再次打开程序、异常退出记录下载进度
License: MIT License
断点下载,支持后台下载,再次打开程序、异常退出记录下载进度
License: MIT License
建议:加入后台下载功能,
看了一下代码,认为有可以优化的地方,具体如下:
ZFSessionModel.h
中,calculateFileSizeInUnit
和calculateUnit
两个方法改成类方法ZFSessionModel.m
中,具体实现如下:#define kZFGBSize (1024 * 1024 * 1024)
#define kZFMBSize (1024 * 1024)
+ (float)calculateFileSizeInUnit:(unsigned long long)contentLength
{
if(contentLength >= kZFGBSize) { return (float) (contentLength / (float)kZFGBSize); }
else if (contentLength >= kZFMBSize) { return (float) (contentLength / (float)kZFMBSize); }
else if (contentLength >= 1024) { return (float) (contentLength / (float)1024); }
else { return (float) (contentLength); }
}
+ (NSString *)calculateUnit:(unsigned long long)contentLength
{
if(contentLength >= kZFGBSize) { return @"GB"; }
else if(contentLength >= kZFMBSize) { return @"MB"; }
else if(contentLength >= 1024) { return @"KB"; }
else { return @"B"; }
}
同时,个人认为DownloadState
枚举最好更改为如下,以防止名称冲突:
typedef NS_ENUM(NSInteger, ZFDownloadState){
ZFDownloadStateStart = 0, /** 下载中 */
ZFDownloadStateSuspended, /** 下载暂停 */
ZFDownloadStateCompleted, /** 下载完成 */
ZFDownloadStateFailed /** 下载失败 */
};
谢谢
please add carthage support and also concerned about dependency of http://github.com/pokeb/asi-http-request/ as it is no longer maintained
考虑下增加 下载的顺序 全部开始 可选从列表第一个 或者顺序下来
如最多一个下载:
正在下载的不是在第一个,其他的等待,下载完成一定是从列表最顶上可下载的开始下载
全部暂停 全部开始 从来都是 从第一个 开始,没有保存上一次的状态
退出程序 程序重新进入,全部状态都是暂停这个不错。
作者可以考虑下,顺序 以及 保存上次下载状态这个东西
连续暂停和下载切换时,暂停和下载图标切换有问题
1.增加同时下载的最大数量限制
2.增加下载的状态判断(即将下载,暂停中,下载中,下载完成)
项目中用到了另一个大神写的,用的系统的框架,结果出了不少问题,占用内存过大,而且不释放,用ZF测试了下发现没有这个问题,但是zf是ASI为基础,大神能不能出一个AFN的呢?
if(!error)
{
NSLog(@"%@",[error description]);
}
希望加入!!!!!!!!ASI老掉牙了,建议改AFN
if (delegate && [delegate respondsToSelector:didStartSelector]) 这个地方会奔溃。
请问作者,对startLoad没进行调用,自动执行多次,是什么原因呢?比如执行一次- (void)resumeRequest:(ZFHttpRequest *)request后,startLoad会执行两次.
把保存的文件的名字换成自定义的话,下载的方法的block就不走了.PS:我把文件名字添加在下载的方法函数中- (void)download:(NSString *)url progress:(ZFDownloadProgressBlock)progressBlock state:(ZFDownloadStateBlock)stateBlock fileName:(NSString *)name;
pod 提示版本是1.0.2,但是下载下来的却不是最新文件
还有个问题,为啥NSURLsession更换成ASIHTTPRequest
Trapped uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x60000044a860> was mutated while being enumerated.'
[
0 CoreFoundation 0x000000010df5ed4b __exceptionPreprocess + 171,
1 libobjc.A.dylib 0x0000000112cde21e objc_exception_throw + 48,
2 CoreFoundation 0x000000010dfc7f6c __NSFastEnumerationMutationHandler + 124,
3 WLMaster 0x000000010c46f6f5 -[ZFDownloadManager startLoad] + 1493,
4 WLMaster 0x000000010c46c895 -[ZFDownloadManager downFileUrl:filename:videoId:completeBlock:] + 2229,
5 WLMaster 0x000000010c563acd -[WLVideoCacheManager downloadWithData:completeBlock:] + 1325,
6 WLMaster 0x000000010c562fa5 __63-[WLVideoCacheManager addDownTaskToDispatchSemaphoreWithModle:]_block_invoke + 261,
7 libdispatch.dylib 0x000000011437f978 _dispatch_call_block_and_release + 12,
8 libdispatch.dylib 0x00000001143a90cd _dispatch_client_callout + 8,
9 libdispatch.dylib 0x0000000114388312 _dispatch_queue_override_invoke + 1426,
10 libdispatch.dylib 0x000000011438a385 _dispatch_root_queue_drain + 720,
11 libdispatch.dylib 0x000000011438a059 _dispatch_worker_thread3 + 123,
12 libsystem_pthread.dylib 0x0000000114758712 _pthread_wqthread + 1299,
13 libsystem_pthread.dylib 0x00000001147581ed start_wqthread + 13
]
添加下载按钮,全屏状态下,点击下载,视频从全屏会变成小屏,竖屏下,下载没问题
下载的速度远远超过实际的速度
想问下,怎么设置正在下载的个数
使用pod(v1.0.1)时,出现如下错误:
-->
/xxx/Pods/ZFDownload/ZFDownload/ZFHttpRequest.h:25:9: Could not build module 'ASIHTTPRequest'
XCode version : 7.3.1
OSX : 10.11.6
Ps:仅仅使用ZFPlayer时 正常
请问按成为manager代理后,该方法不回调是什么问题?
配合ZFplayer简直完美
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.