// // customDownloadOperation.h // Private-X // // Created by xd h on 2024/7/1. // #import //音频播放下载 加入 后续可以单独删除 #import "audioPlayListManager.h" /** 下载状态*/ typedef enum : NSUInteger { //customDownloadStateWaiting = 0, /** 下载等待中 */ customDownloadStateDoing =0, /** 下载中 */ customDownloadStateSuspended, /** 下载暂停 */ customDownloadStateCompleted, /** 下载完成 */ customDownloadStateFailed, /** 下载失败 */ //customDownloadStateNetWorkFailed, /** 下载时网络中断 */ } customDownloadStateType; NS_ASSUME_NONNULL_BEGIN @interface customDownloadOperation : NSObject /** 绑定的标示及task的创建 */ @property (readonly,nonatomic, copy)NSString *url; /** 下载任务 */ @property (nonatomic,strong,nullable)NSURLSession *session; /** 下载任务 */ @property (nonatomic,strong,nullable)NSURLSessionDataTask *dataTask; @property(nonatomic,assign) BOOL isManualCancel;//手动取消 @property(nonatomic,assign) BOOL isFile404Cancel;//请求文件返回404 /** 文件句柄 可以记录文件的下载的位置 */ @property (nonatomic,strong,nullable) NSFileHandle *handle; /** 下载的文件总大小 */ @property (nonatomic,assign) int64_t totalSize; /** 当前下载了多少 */ @property (nonatomic,assign) int64_t currentSize; /** 当前下载文件名称 */ @property (nonatomic,copy) NSString *fileName; /** 当前下载文件沙盒全路径 */ @property (nonatomic,copy) NSString *fullPath; /** 文件下载状态 */ @property (nonatomic,assign) customDownloadStateType downloadState; /** 下载完成-时间戳 */ @property (nonatomic,assign) NSInteger timeStamp; /** 文件类型 */ @property (nonatomic,assign) NSInteger fileType; /** 是否完成 */ @property (nonatomic, assign) NSInteger isFinished; /** 下载中上次通知的时间 用来控制通知时间的频率 目前定位一秒 */ @property (nonatomic, assign) NSTimeInterval preNotTimeInterval; // 创建下载操作任务 - (instancetype)initWith:(NSString *)url session:(NSURLSession *)session; // downloadType 不传 即为原来的 分享链接唤起的下载 // downloadType audioPlayCache 为音乐播放下载缓存 - (instancetype)initWith:(NSString *)url session:(NSURLSession *)session withType:(NSString*)downloadType; - (NSDictionary *)downLoadInfoWithFinished:(BOOL)finished; @end NS_ASSUME_NONNULL_END