FSParsePlaylistRequest.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * This file is part of the FreeStreamer project,
  3. * (C)Copyright 2011-2018 Matias Muhonen <mmu@iki.fi> 穆马帝
  4. * See the file ''LICENSE'' for using the code.
  5. *
  6. * https://github.com/muhku/FreeStreamer
  7. */
  8. #import <Foundation/Foundation.h>
  9. /**
  10. * The playlist format.
  11. */
  12. typedef NS_ENUM(NSInteger, FSPlaylistFormat) {
  13. /**
  14. * Unknown playlist format.
  15. */
  16. kFSPlaylistFormatNone,
  17. /**
  18. * M3U playlist.
  19. */
  20. kFSPlaylistFormatM3U,
  21. /**
  22. * PLS playlist.
  23. */
  24. kFSPlaylistFormatPLS
  25. };
  26. /**
  27. * FSParsePlaylistRequest is a class for parsing a playlist. It supports
  28. * the M3U and PLS formats.
  29. *
  30. * To use the class, define the URL for retrieving the playlist using
  31. * the url property. Then, define the onCompletion and onFailure handlers.
  32. * To start the request, use the start method.
  33. */
  34. @interface FSParsePlaylistRequest : NSObject<NSURLSessionDelegate> {
  35. NSURLSessionTask *_task;
  36. NSInteger _httpStatus;
  37. NSMutableData *_receivedData;
  38. NSMutableArray *_playlistItems;
  39. FSPlaylistFormat _format;
  40. }
  41. /**
  42. * The URL of this request.
  43. */
  44. @property (nonatomic,copy) NSURL *url;
  45. /**
  46. * Called when the playlist parsing is completed.
  47. */
  48. @property (copy) void (^onCompletion)(void);
  49. /**
  50. * Called if the playlist parsing failed.
  51. */
  52. @property (copy) void (^onFailure)(void);
  53. /**
  54. * The playlist items stored in the FSPlaylistItem class.
  55. */
  56. @property (readonly) NSMutableArray *playlistItems;
  57. /**
  58. * Starts the request.
  59. */
  60. - (void)start;
  61. /**
  62. * Cancels the request.
  63. */
  64. - (void)cancel;
  65. @end