XYLiveManger.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. //
  2. // XYLiveManger.h
  3. // Starbuds
  4. //
  5. // Created by pajia on 2019/12/31.
  6. // Copyright © 2019 翟玉磊. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "XYLiveRoomMessageInfo.h"
  10. #import "AWRichText.h"
  11. #import "XYLiveMessageManager.h"
  12. #import "HDWindowLogger.h"
  13. #import "XYLiveRoomVCInfo.h"
  14. #import "XYFeedModel.h"
  15. #import "XYUserMarkIconView.h"
  16. /// 表情在AWRT中的tag
  17. static NSString * const EXPRESSION_AWRTVIEW_TAG = @"EXPRESSION_AWRTVIEW_TAG";
  18. @interface XYLiveManger : NSObject
  19. typedef NS_ENUM(NSInteger, LiveRoomCurrentUserRole) {
  20. LiveRoomCurrentUserRoleUnknow = 0,
  21. LiveRoomCurrentUserRoleAnchor = 1,//主播 分配房管和禁言和解禁
  22. LiveRoomCurrentUserRoleManager = 2,//房管 禁言和解禁
  23. LiveRoomCurrentUserRoleNospeak = 3,//禁言
  24. LiveRoomCurrentUserRoleSuperManager = 5,//下线并金箔
  25. };
  26. typedef NS_ENUM(NSInteger, LiveRoomBeautyType) {
  27. LiveRoomBeautyTypeUnknow,//
  28. LiveRoomBeautyTypeWhiten, //美白
  29. LiveRoomBeautyTypeSmooth, //磨皮
  30. LiveRoomBeautyTypeRedRosy, //红润
  31. LiveRoomBeautyTypeHighLight, //去高光
  32. LiveRoomBeautyTypeFaceLift, //瘦脸
  33. LiveRoomBeautyTypeEnlargeEye, //大眼
  34. LiveRoomBeautyTypeSmallFace, //小脸
  35. LiveRoomBeautyTypeFaceOverall, //窄脸
  36. LiveRoomBeautyTypeRoundEyes, //圆眼
  37. LiveRoomBeautyTypeJaw, //下巴
  38. LiveRoomBeautyTypeForehead, //额头
  39. LiveRoomBeautyTypeAppleMuscle, //苹果肌
  40. LiveRoomBeautyTypeThinNose, //瘦鼻翼
  41. LiveRoomBeautyTypeProboscides, //长鼻
  42. LiveRoomBeautyTypeFliter,//
  43. LiveRoomBeautyTypeSticker,//
  44. LiveRoomBeautyTypeFliterValue,//
  45. };
  46. typedef enum{
  47. YQSlideStateDef = 0,
  48. YQSlideStateNor = 1,
  49. YQSlideStateUp = 2,
  50. YQSlideStateDown = 3
  51. }YQSlideState;
  52. +(XYLiveManger *)shareInstance;
  53. @property (nonatomic, readwrite, assign) BOOL closeMicrophone;
  54. @property (nonatomic, readwrite, assign) BOOL bannerAnmiShadow;
  55. @property (nonatomic, readwrite, assign) BOOL isShortVideoing;
  56. @property (nonatomic, assign) LiveRoomType liveRoomType;
  57. @property (nonatomic, strong) XYLiveRoomVCInfo *liveRoomVCInfo;
  58. @property (nonatomic, strong) XYFeedModel *shortVideoInfo;
  59. @property (nonatomic, strong) NSString *anchorCoverPath;
  60. @property (nonatomic, strong) NSDictionary *scoreLevelInfoDataDict;
  61. @property (nonatomic, assign) BOOL HDWindowLoggerShow;
  62. - (NSString *)stringFromTxtFile:(NSString *)path;
  63. - (NSString*)dictionaryToJson:(NSDictionary *)dic;
  64. - (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;
  65. - (UIImage *)convertViewToImage:(UIView *)view;
  66. - (NSMutableArray *)leftRightTopBottomArrangeWithDatas:(NSArray *)datas;
  67. @property (nonatomic, assign) LiveRoomCurrentUserRole liveRoomCurrentUserRole;
  68. ///房间聊天列表、个人详情,设置用户标签(等级等),richText后面追加内容(名字lable)
  69. - (void)setUserMarks:(XYLiveRoomMessageInfo *)info andRichText:(AWRichText *)richText;
  70. - (UIImage *)getGradeNumImage:(XYLiveRoomMessageInfo *)info;
  71. - (UIImage *)getAnchorGradeNumImage:(XYLiveRoomMessageInfo *)info;
  72. - (void)stopAnchorLiveRoom;
  73. - (void)requestGiftListUserScoreData;
  74. - (void)beautyEffectViewClear;
  75. - (void)saveBeautyDefaultValue;
  76. - (void)setBeautyDefaultValue:(LiveRoomBeautyType )type andValue:(NSString *)value;
  77. - (NSString *)getBeautyDefaultValue:(LiveRoomBeautyType )type;
  78. @property (nonatomic, readwrite, strong) NSString *currentFilterName;
  79. @property (nonatomic, readwrite, strong) NSString *currentFilterPath;
  80. @property (nonatomic, readwrite, strong) NSString *currentFilterValue;
  81. @property (nonatomic, readwrite, strong) NSString *filterPath0;
  82. @property (nonatomic, readwrite, strong) NSString *filterValue0;
  83. @property (nonatomic, readwrite, strong) NSString *filterPath1;
  84. @property (nonatomic, readwrite, strong) NSString *filterValue1;
  85. @property (nonatomic, readwrite, strong) NSString *filterPath2;
  86. @property (nonatomic, readwrite, strong) NSString *filterValue2;
  87. @property (nonatomic, readwrite, strong) NSString *filterPath3;
  88. @property (nonatomic, readwrite, strong) NSString *filterValue3;
  89. @property (nonatomic, readwrite, strong) NSString *filterPath4;
  90. @property (nonatomic, readwrite, strong) NSString *filterValue4;
  91. @property (nonatomic, readwrite, strong) NSString *filterPath5;
  92. @property (nonatomic, readwrite, strong) NSString *filterValue5;
  93. @property (nonatomic, readwrite, strong) NSString *filterPath6;
  94. @property (nonatomic, readwrite, strong) NSString *filterValue6;
  95. @property (nonatomic, readwrite, strong) NSString *currentCity;
  96. - (void)saveFilterDefault;
  97. - (void)setFilterDefault;
  98. //- (void)setFilterDefaultPath:(NSString *)path andValue:(NSString *)value;
  99. //- (NSString *)getFilterDefaultPath:(LiveRoomBeautyType )type;
  100. //- (NSString *)getFilterDefaultValue:(LiveRoomBeautyType )type;
  101. - (NSString *)caluteWValue:(NSInteger )a;
  102. @property (nonatomic, copy) void(^AppBackBackgroundBlock)(BOOL background);
  103. @property (nonatomic, copy) void(^AppBackBackgroundBlock1)(BOOL background);
  104. @property (nonatomic, copy) void(^AppBackBackgroundBlock2)(BOOL background);
  105. @property (nonatomic, copy) void(^AppLogoutBlock)(BOOL logout);
  106. @property (nonatomic, copy) void(^AppRestartPushBlock)(BOOL restartPush);
  107. @property (nonatomic, copy) void(^AppPushSteamSpeedBlock)(NSString *speed);
  108. @property (nonatomic, copy) void(^AppCameraMicBlock)(BOOL success);
  109. @property (nonatomic, copy) void(^AppCloseMicrophoneBlock)(BOOL mute);
  110. @property (nonatomic, copy) void(^AppShortVideoShareBlock)(BOOL success);
  111. @property (nonatomic, copy) void(^AppShortVideoPlayBlock)(BOOL success);
  112. @property (nonatomic, readwrite, strong) NSString *currentRoomFansName;
  113. - (CGSize )getABstringSize:(NSAttributedString *)abString;
  114. - (void)judgeCameraMic;
  115. - (void)keepBrightScreen;
  116. - (void)cancelKeepBrightScreen;
  117. //userid当前直播间uid 毕传
  118. //extraInfo预留实体 可不传
  119. - (void)pushLiveRoom:(NSString *)userid extra:(XYLiveRoomVCInfo *)extraInfo;
  120. - (UIView *)getSvgaView:(XYLiveRoomMessageInfo *)info;
  121. - (NSAttributedString *)formatMessageString:(NSString *)text;
  122. #define SLIDEHEIGHT 100
  123. #define kPFSCFont @"PingFang SC"
  124. #define kPFSCMediumFont @"PingFangSC-Medium"
  125. #define kWEAKSELF typeof(self) __weak weakSelf = self;
  126. #define kSTRONGSELF typeof(weakSelf) __strong strongSelf = weakSelf;
  127. #define kiPhoneXTopEdge (IS_IPHONE_X ? 22.0f : 0.0f)
  128. #define kiPhoneXBottomEdge (IS_IPHONE_X ? 33.0f : 0.0f)
  129. #define kViewRadius(View, Radius)\
  130. \
  131. [View.layer setCornerRadius:(Radius)];\
  132. [View.layer setMasksToBounds:YES]
  133. #define kViewBorderRadius(View, Radius, Width, Color)\
  134. \
  135. [View.layer setCornerRadius:(Radius)];\
  136. [View.layer setMasksToBounds:YES];\
  137. [View.layer setBorderWidth:(Width)];\
  138. [View.layer setBorderColor:[Color CGColor]]
  139. #define kLineHeight 0.5
  140. #define KLiveRoomChatListCellFont [UIFont fontWithName:kPFSCFont size:16]
  141. ///两个cell间距
  142. #define KLiveRoomChatListCellBothShadowMargin 12
  143. ///文字距离阴影背景左边间距
  144. #define KLiveRoomChatListCellStringLeftOrRightMargin 12
  145. ///文字距离阴影背景底部间距
  146. #define KLiveRoomChatListCellStringTopOrBottomMargin 6
  147. ///cell宽度
  148. #define KLiveRoomChatListCellWidth kXY_SCREEN_WIDTH - 10 - 85 - 15
  149. ///聊天、礼物消息时文字宽度
  150. #define KLiveRoomChatListCellTextGiftRichTextLableWidth KLiveRoomChatListCellWidth - 2*KLiveRoomChatListCellStringLeftOrRightMargin - 38
  151. ///提醒、活动消息时文字宽度
  152. #define KLiveRoomChatListCellAlertActivityTichTextLableWidth KLiveRoomChatListCellWidth - 2*KLiveRoomChatListCellStringLeftOrRightMargin
  153. #define kXY_SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
  154. #define kXY_SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
  155. #define YQ_MESSAGE_LIVE_SENDUSER_GIFT 41
  156. #define KLiveRoomBannerGiftAnimWidth 158
  157. #define KLiveRoomBannerGiftAnimHeight 32
  158. #define kSetUserDefaults(object, key) \
  159. ({ \
  160. NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; \
  161. [defaults setObject:object forKey:key]; \
  162. [defaults synchronize]; \
  163. })
  164. #define kGetUserDefaults(key) [[NSUserDefaults standardUserDefaults] objectForKey:key]
  165. #define kRemoveUserDefaults(key) \
  166. ({ \
  167. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; \
  168. [defaults removeObjectForKey:_key]; \
  169. [defaults synchronize]; \
  170. })
  171. #define kRemoveAllUserDefaults [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:[[NSBundle mainBundle] bundleIdentifier]]
  172. //获取沙盒 temp
  173. #define kPathTemp NSTemporaryDirectory()
  174. //获取沙盒 Document
  175. #define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
  176. //获取沙盒 Cache
  177. #define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]
  178. //Library/Caches 文件路径
  179. #define kFilePath ([[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil])
  180. #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  181. #define UIColorFromRGBValue(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  182. #define UIColorFromRGBValueAlpha(rgbValue,alp) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:alp]
  183. #define weakObj(o) autoreleasepool{} __weak typeof(o) o##Weak = o;
  184. #define strongObj(o) autoreleasepool{} __strong typeof(o) o = o##Weak;
  185. #define RUBIKREGULAR @"PingFang SC"
  186. #define Scale_X 1 //[[UIScreen mainScreen] bounds].size.width/375.0
  187. #define Scale_Y 1 //[[UIScreen mainScreen] bounds].size.height/667.0
  188. #define Scale_Font Scale_X
  189. #define RegularFont(s) [UIFont fontWithName:RUBIKREGULAR size:(s)*Scale_Font]
  190. #define MediumFont(s) [UIFont fontWithName:RUBIKREGULAR size:(s)*Scale_Font]
  191. #define ScreenHeight ([UIScreen mainScreen].applicationFrame.size.height)
  192. #define ScreenWidth ([UIScreen mainScreen].applicationFrame.size.width)
  193. #define YQ_SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width
  194. #define YQ_SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height
  195. #define STATUS_BAR_HEIGHT (IS_IPHONE_X ? 44.f : 20.f)
  196. #define JCKeyBoardNumHeight (250 + 40 + kiPhoneXBottomEdge)
  197. #define REQUEST_SUC @"0"
  198. #define REQUEST_INVALID @"1000"
  199. NS_ASSUME_NONNULL_BEGIN
  200. @end
  201. NS_ASSUME_NONNULL_END