UGCKitBGMHelper.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright (c) 2019 Tencent. All rights reserved.
  2. #import <Foundation/Foundation.h>
  3. #define BGM_DEBUG 1
  4. #define BGMLog(...) {\
  5. if(BGM_DEBUG)NSLog(__VA_ARGS__);\
  6. }
  7. #define ASLocalizedString(key) [NSString stringWithFormat:@"%@", [[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"appLanguage"]] ofType:@"lproj"]] localizedStringForKey:(key) value:nil table:@"ASLocalized"]]
  8. NS_ASSUME_NONNULL_BEGIN
  9. @interface TCBGMElement : NSObject
  10. @property NSString* name;
  11. @property NSString* netUrl;
  12. @property NSString* localUrl;
  13. @property NSString* author;
  14. @property NSString* title;
  15. @property NSNumber* duration;//float MicroSeconds
  16. @property NSNumber* isValid;
  17. @end
  18. @protocol TCBGMHelperListener <NSObject>
  19. /**
  20. 从json文件创建BGM列表,失败dict返回nil
  21. */
  22. @required
  23. -(void) onBGMListLoad:(nullable NSDictionary*)dict;
  24. /**
  25. 每首BGM的进度回调
  26. */
  27. @optional
  28. -(void) onBGMDownloading:(TCBGMElement*)current percent:(float)percent;
  29. /**
  30. 下载结束回调,失败current返回nil
  31. */
  32. @optional
  33. -(void) onBGMDownloadDone:(TCBGMElement*)element;
  34. @end
  35. @interface UGCKitBGMHelper : NSObject
  36. -(void) setDelegate:(nonnull id<TCBGMHelperListener>) delegate;
  37. -(void) initBGMListWithJsonFile:(NSString* _Nonnull)url;
  38. + (instancetype)sharedInstance;
  39. /**
  40. 下载BGM
  41. 新任务->新下载
  42. 当前正在下载->暂停下载
  43. 当前暂停->恢复下载
  44. 当前下载完成->重新下载
  45. @param name BGM名称
  46. */
  47. -(void) downloadBGM:(TCBGMElement*) name;
  48. //-(void) pauseAllTasks;
  49. //
  50. //-(void) resumeAllTasks;
  51. @end
  52. NS_ASSUME_NONNULL_END