KBDownloadFile.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // KBYTDownloadStream.h
  3. // Seas0nPass
  4. //
  5. // Created by Kevin Bradley on 3/9/07.
  6. // Copyright 2007 nito, LLC. All rights reserved.
  7. //
  8. #import <Cocoa/Cocoa.h>
  9. /**
  10. This class is used for downloading files from youtube, it takes care of fixing and multiplexing streams when necessary
  11. feed it a stream into downloadStream method and it will take care of the rest.
  12. */
  13. @protocol KBDownloadFileDelegate
  14. - (void)downloadFinished:(NSString *)downloadFile;
  15. - (void)downloadFailed:(NSString *)downloadFile;
  16. - (void)setDownloadProgress:(double)theProgress;
  17. @end
  18. @interface KBDownloadFile : NSObject <NSURLDownloadDelegate> {
  19. NSURLDownload *urlDownload;
  20. NSURLResponse *myResponse;
  21. float bytesReceived;
  22. NSString *downloadLocation;
  23. long long updateFrequency;
  24. long long freq;
  25. NSString *videoDownloadLocation;
  26. }
  27. typedef void (^CompletionHandler)();
  28. @property NSMutableDictionary <NSString *, CompletionHandler>*completionHandlers;
  29. @property (strong, atomic) void (^ProgressBlock)(double percentComplete);
  30. @property (strong, atomic) void (^FancyProgressBlock)(double percentComplete, NSString *status);
  31. @property (strong, atomic) void (^CompletedBlock)(NSString *downloadedFile);
  32. typedef void(^DownloadProgressBlock)(double percentComplete);
  33. typedef void(^FancyDownloadProgressBlock)(double percentComplete, NSString *downloadedFile);
  34. typedef void(^DownloadCompletedBlock)(NSString *downloadedFile);
  35. @property (nonatomic, retain) NSString *downloadLocation;
  36. @property (readwrite, assign) NSInteger downloadMode; //0 = muxed file, 1 = demuxed tracks
  37. - (void)downloadURL:(NSURL *)url toLocation:(NSString *)dlLocation
  38. progress:(DownloadProgressBlock)progressBlock
  39. completed:(DownloadCompletedBlock)completedBlock;
  40. - (void)downloadFileWithURL:(NSURL *)url
  41. toLocation:(NSString *)dlLocation
  42. progress:(DownloadProgressBlock)progressBlock
  43. completed:(DownloadCompletedBlock)completedBlock;
  44. - (long long)updateFrequency;
  45. - (void)setUpdateFrequency:(long long)newUpdateFrequency;
  46. - (void)setDownloadResponse:(NSURLResponse *)response;
  47. - (void)cancel;
  48. @end