YOUPAILZLiveAnchorVC.m 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299
  1. //
  2. // YOUPAILZLiveAnchorVC.m
  3. // TIANYAN
  4. //
  5. // Created by CY on 2021/5/8.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZLiveAnchorVC.h"
  9. #import "FUAPIDemoBar.h"
  10. #import "FUManager.h"
  11. #import "YOUPAILZStartLiveView.h"
  12. #import "YOUPAILZAnchorMenuView.h"
  13. #import "LZAlertWindow.h"
  14. #import "UIViewController+TFPresent.h"
  15. #import "YOUPAILZAnchorLiveCloseVC.h"
  16. #import "YOUPAILZLiveInviteVC.h"
  17. #import "YOUPAILZLiveCallWindow.h"
  18. #import "YOUPAILZLiveStartPKModel.h"
  19. #import "YOUPAILZLiveMemberListVC.h"
  20. #import "YOUPAILZLiveMusicListWindow.h"
  21. #import "YOUPAILZMusicModel.h"
  22. #import "YOUPAILZMusicPlayerView.h"
  23. #import "SDCycleScrollView.h"
  24. #import "YOUPAILZLiveBoardCycleViewCell.h"
  25. #import "YOUPAILZLiveMemberButton.h"
  26. #import "YOUPAILZLiveAnchorHotWindow.h"
  27. #import "YOUPAILZCommonGiftView.h"
  28. @interface YOUPAILZLiveAnchorVC ()<FUAPIDemoBarDelegate,SDCycleScrollViewDelegate>
  29. @property (nonatomic, strong) FUAPIDemoBar *youpaipdemoBar; //Tool Bar
  30. @property (nonatomic, weak) UIView *youpaipdemoBarBgV;
  31. @property (nonatomic, weak) UIButton *youpaipsendMessageBtn; // 发送消息按钮
  32. @property (nonatomic, weak) UIButton *youpaipvoiceBtn; // 喇叭按钮
  33. @property (nonatomic, weak) UIButton *youpaipbeautyBtn; // 美颜按钮
  34. @property (nonatomic, weak) UIButton *youpaipchangeCameraBtn; // 切换摄像头
  35. @property (nonatomic, weak) YOUPAILZStartLiveView *youpaipstartLiveView; // 开始直播页面
  36. @property (nonatomic, weak) UILabel *youpaipliveMemberCountL; // 直播人数
  37. @property (nonatomic, strong) NSMutableArray <YOUPAILZLiveMemberButton *> *youpaipmemberBtns; ///直播榜单人数
  38. @property (nonatomic, weak) UIView *youpaiprankBgV; // 排行背景View
  39. @property (nonatomic, weak) SDCycleScrollView *youpaipboardCycleView; // 当前直播间上榜信息View
  40. @property (nonatomic, weak) UILabel *youpaipfansCountL; // 粉丝数
  41. @property (nonatomic, weak) UIButton *youpaiplianmaiBtn; // 连麦按钮
  42. @property (nonatomic, weak) UIButton *youpaippkBtn; // pk按钮
  43. @property (nonatomic, weak) UIButton *youpaiprePKBtn; // 重新PK按钮
  44. @property (nonatomic, strong)YOUPAILZLiveStartPKModel *youpaipstartPKModel;
  45. @property (nonatomic, assign)LZLiveInviteType youpaipinviteType;
  46. @property (nonatomic, strong) YOUPAILZAnchorMenuView *youpaipmenuView;
  47. @property (nonatomic, assign) LZLivePKState youpaippkState;
  48. @property (nonatomic, strong) NSMutableArray <YOUPAILZMusicListItemModel *> *youpaipmusicList; // 歌单
  49. @property (nonatomic, strong) YOUPAILZMusicListItemModel *currentMusic; // 当前音乐
  50. //@property (nonatomic, assign) AgoraAudioMixingStateCode youpaipmusicPlayState; // 音乐播放状态
  51. @property (nonatomic, weak) YOUPAILZMusicPlayerView *youpaipmusicPlayerView; // 音乐-歌词展示
  52. @property (nonatomic, assign) CGFloat youpaipmusicPlayerViewY;
  53. @end
  54. @implementation YOUPAILZLiveAnchorVC
  55. - (void)dealloc{
  56. NSString *cls = NSStringFromClass([self class]);
  57. NSLog(@"销毁:--%@ dealloc",cls);
  58. }
  59. - (void)viewWillAppear:(BOOL)animated{
  60. [super viewWillAppear:animated];
  61. // [IQKeyboardManager sharedManager].enable = NO;
  62. // [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
  63. [LCSaveData saveIsVideo:YES];
  64. }
  65. - (void)viewWillDisappear:(BOOL)animated{
  66. [super viewWillDisappear:animated];
  67. // [IQKeyboardManager sharedManager].enable = YES;
  68. // [IQKeyboardManager sharedManager].enableAutoToolbar = YES;
  69. }
  70. - (void)viewDidDisappear:(BOOL)animated{
  71. [super viewDidDisappear:animated];
  72. [self youpaifstopMusicPlayer];
  73. [[NSNotificationCenter defaultCenter] removeObserver:self];
  74. }
  75. - (void)youpaifstopMusicPlayer{
  76. [self.youpaipmusicPlayerView youpaifstopTimer];
  77. [self.youpaipmusicPlayerView removeFromSuperview];
  78. self.youpaipmusicPlayerView = nil;
  79. }
  80. - (void)viewDidLoad {
  81. [self youpaifsetupBeautyBar];
  82. [super viewDidLoad];
  83. [self demoBarSetBeautyDefultParams];
  84. [self youpaifsetupStartLiveView];
  85. [self youpaifhandleBlock];
  86. }
  87. /// 女神直播回调
  88. - (void)youpaifhandleBlock{
  89. @weakify(self);
  90. [self setYoupaipliveCloseBlock:^{
  91. @strongify(self);
  92. [self youpaifrequestCloseLiveData];
  93. }];
  94. [self setYoupaippkBlock:^(YOUPAILZLivePKAttachment * _Nonnull pkAttachment) {
  95. @strongify(self);
  96. [self youpaifhandlePKOrLianMaiWithTypeStr:pkAttachment.type pkid:pkAttachment.id type:LZLiveInviteTypePK OperateUid:pkAttachment.operate_uid];
  97. }];
  98. [self setYoupaiplianmaiBlock:^(YOUPAILZLiveLianMaiAttachment * _Nonnull lianmaiAttachment) {
  99. @strongify(self);
  100. [self youpaifhandlePKOrLianMaiWithTypeStr:lianmaiAttachment.type pkid:lianmaiAttachment.id type:LZLiveInviteTypeLianMai OperateUid:lianmaiAttachment.operate_uid];
  101. }];
  102. [self.youpaippkdataView setCurrentPKStateBlock:^(LZLivePKState state) {
  103. @strongify(self);
  104. self.youpaippkState = state;
  105. }];
  106. [self.youpaippkdataView setShowRePKBlock:^(BOOL show) {
  107. @strongify(self);
  108. self.youpaiprePKBtn.hidden = !show;
  109. }];
  110. [self setYoupaipremoteVideoCloseBlock:^{
  111. @strongify(self);
  112. self.youpaippkdataView.youpaipisStartPK = NO;
  113. self.youpaiprePKBtn.hidden = YES;
  114. }];
  115. [self setYoupaipresetPKDataBlock:^(YOUPAILZLivePKDataAttachment * _Nonnull attachment) {
  116. @strongify(self);
  117. self.youpaipstartPKModel.youpaippk_id = attachment.id;
  118. }];
  119. [self setYoupaipmusicPlayFinishBlock:^{
  120. @strongify(self);
  121. [self youpaifnextMusic];
  122. }];
  123. // [self setYoupaipmusicPlayStateBlock:^(AgoraAudioMixingStateCode stateCode) {
  124. // @strongify(self);
  125. // self.youpaipmusicPlayState = stateCode;
  126. // [[NSNotificationCenter defaultCenter] postNotificationName:@"MusicPlayStateChangeNotification" object:@(self.youpaipmusicPlayState) userInfo:nil];
  127. // }];
  128. [self setYoupaipclickRemoteVideoViewBlock:^(NSString * _Nonnull uid, NSString * _Nonnull room_id) {
  129. @strongify(self);
  130. if (uid.length != 0) {
  131. [self youpaifshowUserInfoWithUserId:uid];
  132. }
  133. }];
  134. }
  135. /// 根据类型处理PK、连麦
  136. - (void)youpaifhandlePKOrLianMaiWithTypeStr:(NSString *)typeStr pkid:(NSString *)pkid type:(LZLiveInviteType)type OperateUid:(NSString *)operateUid{
  137. if ([typeStr isEqual:@"call"]) {
  138. [self youpaifrequestObtainInteractWithPkId:pkid type:type];
  139. }else if ([typeStr isEqual:@"timeout"]){
  140. [ZCHUDHelper showTitle:@"已超时"];
  141. [[NSNotificationCenter defaultCenter] postNotificationName:@"RemoveLiveCallWindow" object:nil];
  142. }else if ([typeStr isEqual:@"cancel"]){
  143. [ZCHUDHelper showTitle:@"对方已取消"];
  144. [[NSNotificationCenter defaultCenter] postNotificationName:@"RemoveLiveCallWindow" object:nil];
  145. }else if ([typeStr isEqual:@"hangup"]){
  146. self.youpaipstartPKModel = nil;
  147. if ([self.youpaipliveModel.youpaipuser_info.youpaipuser_id isEqual:operateUid]) {
  148. [ZCHUDHelper showTitle:@"已挂断"];
  149. }else{
  150. [ZCHUDHelper showTitle:@"对方已挂断"];
  151. }
  152. [self.youpaipagoraKit stopChannelMediaRelay];
  153. if (self.youpaipinviteType == LZLiveInviteTypePK) {
  154. [self.youpaippkBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_avchor_pk"] forState:UIControlStateNormal];
  155. [self.youpaippkBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_avchor_pk"] forState:UIControlStateHighlighted];
  156. self.youpaippkBtn.selected = NO;
  157. }else{
  158. [self.youpaiplianmaiBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_avchor_lianmai"] forState:UIControlStateNormal];
  159. [self.youpaiplianmaiBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_avchor_lianmai"] forState:UIControlStateHighlighted];
  160. self.youpaiplianmaiBtn.selected = NO;
  161. }
  162. }else if ([typeStr isEqual:@"refuse"]){
  163. [ZCHUDHelper showTitle:@"对方已拒绝"];
  164. [[NSNotificationCenter defaultCenter] postNotificationName:@"RemoveLiveCallWindow" object:nil];
  165. }else if ([typeStr isEqual:@"agree"]){
  166. self.youpaipinviteType = type;
  167. [self youpaifforwardChannel];
  168. [[NSNotificationCenter defaultCenter] postNotificationName:@"RemoveLiveCallWindow" object:nil];
  169. }
  170. }
  171. /// 设置默认美颜属性
  172. - (void)demoBarSetBeautyDefultParams {
  173. [_youpaipdemoBar reloadSkinView:[FUManager shareManager].skinParams];
  174. [_youpaipdemoBar reloadShapView:[FUManager shareManager].shapeParams];
  175. [_youpaipdemoBar reloadFilterView:[FUManager shareManager].filters];
  176. }
  177. /// 设置开始直播页面
  178. - (void)youpaifsetupStartLiveView{
  179. YOUPAILZStartLiveView *youpaipstartLiveView = [[YOUPAILZStartLiveView alloc] initWithFrame:self.view.bounds shareModel:self.youpaipshareModel youpaipcover:self.youpaipcover];
  180. [self.view addSubview:youpaipstartLiveView];
  181. self.youpaipstartLiveView = youpaipstartLiveView;
  182. @weakify(self);
  183. [youpaipstartLiveView setYoupaipcloseClickBlock:^{
  184. @strongify(self);
  185. [self.youpaipmCamera stopCapture];
  186. [LCSaveData saveIsVideo:NO];
  187. self.youpaipagoraKit.delegate = nil;
  188. self.youpaipagoraKit = nil;
  189. [self.navigationController popViewControllerAnimated:YES];
  190. }];
  191. [youpaipstartLiveView setYoupaipchangeCameraClickBlock:^{
  192. @strongify(self);
  193. [self youpaifchangeCamera];
  194. }];
  195. [youpaipstartLiveView setYoupaipbeautyClickBlock:^{
  196. @strongify(self);
  197. [self youpaifshowDemoBar];
  198. }];
  199. [youpaipstartLiveView setYoupaipstartLiveClickBlock:^(YOUPAILZLiveModel * _Nonnull youpaipliveModel) {
  200. @strongify(self);
  201. self.youpaipliveModel = youpaipliveModel;
  202. self.youpaippkdataView.youpaipmodel = youpaipliveModel;
  203. [self youpaifjoin];
  204. [self.youpaipstartLiveView removeFromSuperview];
  205. [self youpaifsetupChatMessageView];
  206. [self youpaifsetupHeaderView];
  207. [self youpaifsetupFooterView];
  208. [self youpaifsetupMusicPlayerView];
  209. [self youpaifloadAdvertRecharge];
  210. }];
  211. }
  212. /// 音乐-歌词展示
  213. - (void)youpaifsetupMusicPlayerView{
  214. @weakify(self);
  215. YOUPAILZMusicPlayerView *youpaipmusicPlayerView = [[YOUPAILZMusicPlayerView alloc]initWithFrame:CGRectMake(self.youpaipchatBgView.mj_w * 0.4f, KScreenHeight / 2.0f, self.youpaipchatBgView.mj_w * 0.6f, 68.0f)];
  216. youpaipmusicPlayerView.hidden = YES;
  217. youpaipmusicPlayerView.showLyric = YES;
  218. [youpaipmusicPlayerView setGetPlayPositionBlock:^NSInteger{
  219. @strongify(self);
  220. return [self.youpaipagoraKit getAudioMixingCurrentPosition];
  221. }];
  222. // 暂停or播放
  223. [youpaipmusicPlayerView setYoupaipsuspendMusicBlock:^{
  224. @strongify(self);
  225. // if (self.youpaipmusicPlayState == AgoraAudioMixingStatePlaying) {
  226. // [self.youpaipagoraKit pauseAudioMixing];
  227. // }else{
  228. // [self.youpaipagoraKit resumeAudioMixing];
  229. // }
  230. }];
  231. [self.youpaipchatBgView addSubview:youpaipmusicPlayerView];
  232. self.youpaipmusicPlayerView = youpaipmusicPlayerView;
  233. UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifmusicHandlePan:)];
  234. [youpaipmusicPlayerView addGestureRecognizer:panGestureRecognizer];
  235. }
  236. - (void)youpaifmusicHandlePan:(UIPanGestureRecognizer*)recognizer{
  237. CGPoint translation = [recognizer translationInView:self.view];
  238. if(recognizer.state == UIViewAnimatingPositionStart){
  239. self.youpaipmusicPlayerViewY = self.youpaipmusicPlayerView.mj_y;
  240. }else if (recognizer.state == UIGestureRecognizerStateChanged) {
  241. self.youpaipmusicPlayerView.mj_y = self.youpaipmusicPlayerViewY + translation.y;
  242. }else if(recognizer.state == UIGestureRecognizerStateEnded || recognizer.state == UIGestureRecognizerStateCancelled) {
  243. [UIView animateWithDuration:0.25f animations:^{
  244. if (self.youpaipmusicPlayerView.mj_y < NavBarHeight) {
  245. self.youpaipmusicPlayerView.mj_y = NavBarHeight;
  246. }else if (self.youpaipmusicPlayerView.mj_y > KScreenHeight - TabbarHeight - self.youpaipmusicPlayerView.mj_h){
  247. self.youpaipmusicPlayerView.mj_y = KScreenHeight - TabbarHeight - self.youpaipmusicPlayerView.mj_h;
  248. }
  249. }];
  250. }
  251. }
  252. /// 设置美颜工具
  253. - (void)youpaifsetupBeautyBar{
  254. // 美颜工具
  255. [self.view layoutIfNeeded];
  256. UIView *youpaipdemoBarBgV = [[UIView alloc] initWithFrame:self.view.bounds];
  257. youpaipdemoBarBgV.hidden = YES;
  258. [self.view addSubview:youpaipdemoBarBgV];
  259. self.youpaipdemoBarBgV = youpaipdemoBarBgV;
  260. [self.youpaipdemoBarBgV addSubview:self.youpaipdemoBar];
  261. self.youpaipdemoBar.frame = CGRectMake(0, KScreenHeight - SafeHeight - 182.0f , KScreenWidth, 182.0f);
  262. }
  263. /// 设置headerView
  264. - (void)youpaifsetupHeaderView{
  265. UIView *headerView = [[UIView alloc] init];
  266. [self.view addSubview:headerView];
  267. [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
  268. make.left.offset(0.0f);
  269. make.height.offset(70.0f);
  270. make.top.offset(StatusBarHeight);
  271. }];
  272. UIButton *anchorInfoBgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  273. anchorInfoBgBtn.layer.cornerRadius = 17.5f;
  274. anchorInfoBgBtn.clipsToBounds = YES;
  275. anchorInfoBgBtn.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  276. anchorInfoBgBtn.tag = [self.youpaipliveModel.youpaipuser_info.youpaipuser_id integerValue];
  277. [anchorInfoBgBtn addTarget:self action:@selector(youpaifshowUserInfoClick:) forControlEvents:UIControlEventTouchUpInside];
  278. [headerView addSubview:anchorInfoBgBtn];
  279. [anchorInfoBgBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  280. make.left.offset(12.0f);
  281. make.top.offset(5.0f);
  282. make.height.offset(35.0f);
  283. make.width.lessThanOrEqualTo(140.0f);
  284. make.right.offset(0.0f);
  285. }];
  286. UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
  287. youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  288. youpaipavatarImgV.layer.cornerRadius = 16.5f;
  289. youpaipavatarImgV.clipsToBounds = YES;
  290. [youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipliveModel.youpaipuser_info.youpaipavatar]];
  291. [anchorInfoBgBtn addSubview:youpaipavatarImgV];
  292. [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  293. make.left.top.offset(1.0f);
  294. make.size.mas_offset(CGSizeMake(33.0f, 33.0f));
  295. }];
  296. UIImageView *anchorTagImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_anchor_vlog"]];
  297. [anchorInfoBgBtn addSubview:anchorTagImgV];
  298. [anchorTagImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  299. make.right.equalTo(youpaipavatarImgV.mas_right).offset(0.0f);
  300. make.bottom.equalTo(youpaipavatarImgV.mas_bottom).offset(0.0f);
  301. make.size.mas_offset(CGSizeMake(10.0f, 10.0f));
  302. }];
  303. UILabel *youpaipnicknameL = [[UILabel alloc] init];
  304. youpaipnicknameL.font = LCBoldFont(11.0f);
  305. youpaipnicknameL.textColor = [UIColor whiteColor];
  306. youpaipnicknameL.text = self.youpaipliveModel.youpaipuser_info.youpaipnickname;
  307. [anchorInfoBgBtn addSubview:youpaipnicknameL];
  308. [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  309. make.left.equalTo(youpaipavatarImgV.mas_right).offset(4.0f);
  310. make.right.offset(-12.0f);
  311. make.top.offset(5.0f);
  312. // make.height.offset(17.5f);
  313. }];
  314. UILabel *youpaipfansCountL = [[UILabel alloc] init];
  315. youpaipfansCountL.font = LCFont(8.0f);
  316. youpaipfansCountL.textColor = [UIColor whiteColor];
  317. youpaipfansCountL.text = [NSString stringWithFormat:@"粉丝:%@",self.youpaipliveModel.youpaipfans_count];
  318. [anchorInfoBgBtn addSubview:youpaipfansCountL];
  319. self.youpaipfansCountL = youpaipfansCountL;
  320. [youpaipfansCountL mas_makeConstraints:^(MASConstraintMaker *make) {
  321. make.left.equalTo(youpaipavatarImgV.mas_right).offset(4.0f);
  322. make.right.offset(-12.0f);
  323. make.bottom.offset(-5.0f);
  324. // make.height.offset(17.5f);
  325. }];
  326. UIButton *closeLiveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  327. [closeLiveBtn setImage:[UIImage imageNamed:@"vqu_images_L_live_anchor_close"] forState:UIControlStateNormal];
  328. [closeLiveBtn setImage:[UIImage imageNamed:@"vqu_images_L_live_anchor_close"] forState:UIControlStateHighlighted];
  329. [closeLiveBtn addTarget:self action:@selector(youpaifendLive) forControlEvents:UIControlEventTouchUpInside];
  330. [self.view addSubview:closeLiveBtn];
  331. [closeLiveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  332. make.right.offset(-12.0f);
  333. make.top.offset(7.0f + StatusBarHeight);
  334. make.height.offset(31.0f);
  335. make.width.offset(19.0f);
  336. }];
  337. UIButton *liveMemberCountBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  338. liveMemberCountBtn.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  339. liveMemberCountBtn.layer.cornerRadius = 15.5f;
  340. liveMemberCountBtn.clipsToBounds = YES;
  341. [liveMemberCountBtn addTarget:self action:@selector(youpaifliveMemberCountBtnClick) forControlEvents:UIControlEventTouchUpInside];
  342. [self.youpaipchatBgView addSubview:liveMemberCountBtn];
  343. [liveMemberCountBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  344. make.right.offset(-1.0f-19.0f-12.0f);
  345. make.top.offset(7.0f + StatusBarHeight);
  346. make.height.offset(31.0f);
  347. make.width.greaterThanOrEqualTo(31.0f);
  348. }];
  349. UILabel *youpaipliveMemberCountL = [[UILabel alloc] init];
  350. youpaipliveMemberCountL.font = LCFont(12.0f);
  351. youpaipliveMemberCountL.textColor = [UIColor whiteColor];
  352. youpaipliveMemberCountL.textAlignment = NSTextAlignmentCenter;
  353. youpaipliveMemberCountL.text = @"0";
  354. [liveMemberCountBtn addSubview:youpaipliveMemberCountL];
  355. self.youpaipliveMemberCountL = youpaipliveMemberCountL;
  356. [youpaipliveMemberCountL mas_makeConstraints:^(MASConstraintMaker *make) {
  357. make.left.offset(7.0f);
  358. make.top.bottom.offset(0.0f);
  359. make.right.offset(-7.0f);
  360. }];
  361. @weakify(self);
  362. [self setYoupaipliveMemberCountChangeBlock:^(NSInteger memberCount) {
  363. @strongify(self);
  364. self.youpaipliveMemberCountL.text = [NSString stringWithFormat:@"%@",@(memberCount)];
  365. }];
  366. UIView *youpaiprankBgV = [[UIView alloc] init];//WithFrame:CGRectMake(liveMemberCountBtn.mj_x - 4.0f, 7.0f, 0.0f, 31.0f)
  367. [self.youpaipchatBgView addSubview:youpaiprankBgV];
  368. self.youpaiprankBgV = youpaiprankBgV;
  369. [youpaiprankBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  370. make.right.equalTo(liveMemberCountBtn.mas_left).offset(-4.0f);
  371. make.top.offset(7.0f + StatusBarHeight);
  372. make.height.offset(31.0f);
  373. make.width.offset(0.0f);
  374. }];
  375. [self youpaifupdateMemberInfo];
  376. [self setYoupaipliveMemberListChangeBlock:^(NSArray * _Nonnull members) {
  377. @strongify(self);
  378. self.youpaipliveModel.youpaiplive_top_three = [LZLiveTopThreeModel mj_objectArrayWithKeyValuesArray:members];
  379. [self youpaifupdateMemberInfo];
  380. }];
  381. NSMutableArray *arr = [NSMutableArray array];
  382. if (self.youpaipliveModel.youpaipanchor_rank_info.youpaiptotalMoney.youpaipval.length != 0) {
  383. [arr addObject:@"totalMoney"];
  384. }
  385. if (self.youpaipliveModel.youpaipanchor_rank_info.youpaipgapMoney.youpaipval.length != 0) {
  386. [arr addObject:@"gapMoney"];
  387. }
  388. if (self.youpaipliveModel.youpaipanchor_rank_info.youpaipno.youpaipval.length != 0) {
  389. [arr addObject:@"no"];
  390. }
  391. SDCycleScrollView *youpaipboardCycleView = [[SDCycleScrollView alloc] init];
  392. youpaipboardCycleView.backgroundColor = [UIColor clearColor];
  393. youpaipboardCycleView.scrollDirection = UICollectionViewScrollDirectionVertical;
  394. youpaipboardCycleView.autoScrollTimeInterval = 5.0f/arr.count;
  395. youpaipboardCycleView.autoScroll = YES;
  396. youpaipboardCycleView.imageURLStringsGroup = arr.copy;
  397. youpaipboardCycleView.titleLabelTextColor = [UIColor redColor];
  398. youpaipboardCycleView.showPageControl = NO;
  399. youpaipboardCycleView.delegate = self;
  400. [headerView addSubview:youpaipboardCycleView];
  401. self.youpaipboardCycleView = youpaipboardCycleView;
  402. [youpaipboardCycleView mas_makeConstraints:^(MASConstraintMaker *make) {
  403. make.left.offset(14.0f);
  404. make.top.equalTo(anchorInfoBgBtn.mas_bottom).offset(10.0f);
  405. make.height.offset(20.0f);
  406. make.width.offset(150.0f);
  407. }];
  408. [self setYoupaipliveInfoUpdateBlock:^(NSString * _Nonnull anchor_charm, NSString * _Nonnull fans, NSDictionary * _Nonnull anchor_rank_info) {
  409. @strongify(self);
  410. self.youpaipfansCountL.text = [NSString stringWithFormat:@"粉丝:%@",fans];
  411. self.youpaipliveModel.youpaipanchor_rank_info = [LZLiveAnchorRankInfoModel mj_objectWithKeyValues:anchor_rank_info];
  412. NSMutableArray *arr = [NSMutableArray array];
  413. if (self.youpaipliveModel.youpaipanchor_rank_info.youpaiptotalMoney.youpaipval.length != 0) {
  414. [arr addObject:@"totalMoney"];
  415. }
  416. if (self.youpaipliveModel.youpaipanchor_rank_info.youpaipgapMoney.youpaipval.length != 0) {
  417. [arr addObject:@"gapMoney"];
  418. }
  419. if (self.youpaipliveModel.youpaipanchor_rank_info.youpaipno.youpaipval.length != 0) {
  420. [arr addObject:@"no"];
  421. }
  422. self.youpaipboardCycleView.imageURLStringsGroup = arr.copy;
  423. self.youpaipboardCycleView.autoScrollTimeInterval = 5.0f/arr.count;
  424. }];
  425. // UIView *userIdBgV = [[UIView alloc] init];
  426. // userIdBgV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2f];
  427. // userIdBgV.layer.cornerRadius = 8.5f;
  428. // userIdBgV.clipsToBounds = YES;
  429. // [self.youpaipchatBgView addSubview:userIdBgV];
  430. // [userIdBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  431. // make.right.offset(-12.0f);
  432. // make.top.equalTo(anchorInfoBgBtn.mas_bottom).offset(8.0f);
  433. // make.height.offset(17.0f);
  434. // }];
  435. //
  436. // UILabel *userIdL = [[UILabel alloc] init];
  437. // userIdL.font = LCFont(12.0f);
  438. // userIdL.textColor = HexColorFromRGB(0xDDDDDD);
  439. // userIdL.text = [NSString stringWithFormat:@"花舞号 %@",self.youpaipliveModel.user_info.usercode];
  440. // [userIdBgV addSubview:userIdL];
  441. // [userIdL mas_makeConstraints:^(MASConstraintMaker *make) {
  442. // make.left.offset(7.0f);
  443. // make.right.offset(-7.0f);
  444. // make.top.bottom.offset(0.0f);
  445. // }];
  446. UIButton *youpaiprePKBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  447. // youpaiprePKBtn.layer.cornerRadius = 12.0f;
  448. // youpaiprePKBtn.clipsToBounds = YES;
  449. youpaiprePKBtn.frame = CGRectMake(0, 0, 56.0f, 22.0f);
  450. [LCTools clipCorner:UIRectCornerBottomLeft|UIRectCornerBottomRight View:youpaiprePKBtn size:CGSizeMake(5.0f, 5.0f)];
  451. [youpaiprePKBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0x69BCF8),HexColorFromRGB(0x274BE8)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  452. [youpaiprePKBtn setTitle:@"重新PK" forState:UIControlStateNormal];
  453. [youpaiprePKBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  454. youpaiprePKBtn.titleLabel.font = LCFont12;
  455. youpaiprePKBtn.hidden = YES;
  456. [youpaiprePKBtn addTarget:self action:@selector(youpaifrePKBtnClick) forControlEvents:UIControlEventTouchUpInside];
  457. [self.view addSubview:youpaiprePKBtn];
  458. self.youpaiprePKBtn = youpaiprePKBtn;
  459. [youpaiprePKBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  460. make.centerX.equalTo(self.view);
  461. make.top.equalTo(headerView.mas_bottom).offset(8.0f);
  462. make.size.mas_offset(CGSizeMake(56.0f, 22.0f));
  463. }];
  464. }
  465. - (void)youpaifupdateMemberInfo{
  466. [self youpaifeditBtnCountWithCount:self.youpaipliveModel.youpaiplive_top_three.count > 3 ? 3 : self.youpaipliveModel.youpaiplive_top_three.count];
  467. [self.youpaiprankBgV updateConstraints:^(MASConstraintMaker *make) {
  468. make.width.offset(self.youpaipmemberBtns.count * 31.0f + (self.youpaipmemberBtns.count - 1.0f) * 4.0f);
  469. }];
  470. NSArray <UIColor *>*borderColors = @[[HexColorFromRGB(0xFF0000) colorWithAlphaComponent:0.47f],[HexColorFromRGB(0xFFD043) colorWithAlphaComponent:0.47f],[HexColorFromRGB(0x6EF467) colorWithAlphaComponent:0.47f]];
  471. NSArray <UIColor *>*titleBgColors = @[[HexColorFromRGB(0xF46767) colorWithAlphaComponent:0.41f],[HexColorFromRGB(0xFFC104) colorWithAlphaComponent:0.41f],[HexColorFromRGB(0x6EF467) colorWithAlphaComponent:0.41f]];
  472. // for (NSInteger i = 0; i < self.youpaipmemberBtns.count; i ++) {
  473. // YOUPAILZLiveMemberButton *imgBtn = self.youpaipmemberBtns[i];
  474. // imgBtn.layer.cornerRadius = 15.5f;
  475. // imgBtn.clipsToBounds = YES;
  476. // imgBtn.tag = [self.youpaipliveModel.youpaiplive_top_three[i].youpaipid integerValue];
  477. // [imgBtn addTarget:self action:@selector(youpaifshowUserInfoClick:) forControlEvents:UIControlEventTouchUpInside];
  478. // [imgBtn sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipliveModel.youpaiplive_top_three[i].youpaipavatar] forState:UIControlStateNormal];
  479. // imgBtn.frame = CGRectMake(i * 31.0f + i * 4.0f, 0, 31.0f, 31.0f);
  480. // imgBtn.youpaipcountL.text = self.youpaipliveModel.youpaiplive_top_three[i].youpaipscore;
  481. // imgBtn.layer.borderColor = borderColors[i].CGColor;
  482. // imgBtn.layer.borderWidth = 1.0f;
  483. // imgBtn.youpaipcountL.mj_w = 31.0f;
  484. // imgBtn.youpaipcountL.backgroundColor = titleBgColors[i];
  485. // [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:imgBtn.youpaipcountL size:CGSizeMake(6.0f, 6.0f)];
  486. // }
  487. }
  488. /// 设置FooterView
  489. - (void)youpaifsetupFooterView{
  490. UIView *youpaipfooterView = [[UIView alloc] init];
  491. [self.youpaipchatBgView addSubview:youpaipfooterView];
  492. [youpaipfooterView mas_makeConstraints:^(MASConstraintMaker *make) {
  493. make.right.left.offset(0.0f);
  494. make.height.offset(40.0f);
  495. make.bottom.offset(-SafeHeight - 10.0f);
  496. }];
  497. UIButton *sendMessageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  498. sendMessageBtn.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2f];
  499. sendMessageBtn.layer.cornerRadius = 20.0f;
  500. sendMessageBtn.clipsToBounds = YES;
  501. [sendMessageBtn addTarget:self action:@selector(youpaifsendMessageBtnClick) forControlEvents:UIControlEventTouchUpInside];
  502. [youpaipfooterView addSubview:sendMessageBtn];
  503. self.youpaipsendMessageBtn = sendMessageBtn;
  504. [sendMessageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  505. make.left.offset(0.0f);
  506. make.height.offset(40.0f);
  507. make.bottom.offset(0.0f);
  508. make.width.offset(103.0f);
  509. }];
  510. UILabel *youpaiptextL = [[UILabel alloc] init];
  511. youpaiptextL.font = LCFont16;
  512. youpaiptextL.textColor = HexColorFromRGB(0xDDDDDD);
  513. youpaiptextL.text = @"聊聊天…";
  514. [sendMessageBtn addSubview:youpaiptextL];
  515. [youpaiptextL mas_makeConstraints:^(MASConstraintMaker *make) {
  516. make.left.offset(16.0f);
  517. make.top.bottom.offset(0.0f);
  518. }];
  519. UIButton *moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  520. [moreBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_audience_more"] forState:UIControlStateNormal];
  521. [moreBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_audience_more"] forState:UIControlStateHighlighted];
  522. [moreBtn addTarget:self action:@selector(youpaifmoreBtnClick) forControlEvents:UIControlEventTouchUpInside];
  523. [youpaipfooterView addSubview:moreBtn];
  524. [moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  525. make.right.offset(-16.0f);
  526. make.top.offset(0.0f);
  527. make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  528. }];
  529. // 连麦
  530. UIButton *youpaiplianmaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  531. [youpaiplianmaiBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_avchor_lianmai"] forState:UIControlStateNormal];
  532. [youpaiplianmaiBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_avchor_lianmai"] forState:UIControlStateHighlighted];
  533. [youpaiplianmaiBtn addTarget:self action:@selector(youpaiflianmaiBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  534. [youpaipfooterView addSubview:youpaiplianmaiBtn];
  535. self.youpaiplianmaiBtn = youpaiplianmaiBtn;
  536. [youpaiplianmaiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  537. make.right.equalTo(moreBtn.mas_left).offset(-16.0f);
  538. make.top.offset(0.0f);
  539. make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  540. }];
  541. // pk
  542. UIButton *youpaippkBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  543. [youpaippkBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_avchor_pk"] forState:UIControlStateNormal];
  544. [youpaippkBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_avchor_pk"] forState:UIControlStateHighlighted];
  545. [youpaippkBtn addTarget:self action:@selector(youpaifpkBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  546. [youpaipfooterView addSubview:youpaippkBtn];
  547. self.youpaippkBtn = youpaippkBtn;
  548. [youpaippkBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  549. make.right.equalTo(youpaiplianmaiBtn.mas_left).offset(-16.0f);
  550. make.top.offset(0.0f);
  551. make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  552. }];
  553. // 礼物
  554. UIButton *giftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  555. [giftBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_anchor_gift"] forState:UIControlStateNormal];
  556. [giftBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_anchor_gift"] forState:UIControlStateHighlighted];
  557. [giftBtn addTarget:self action:@selector(youpaifgiftBtnClick) forControlEvents:UIControlEventTouchUpInside];
  558. [youpaipfooterView addSubview:giftBtn];
  559. [giftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  560. make.right.equalTo(youpaippkBtn.mas_left).offset(-9.0f);
  561. make.top.offset(0.0f);
  562. make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  563. }];
  564. }
  565. #pragma mark - Click
  566. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  567. [self youpaifhideKayboard];
  568. UITouch* touch = [touches anyObject];
  569. UIView* view = [touch view];
  570. if (view == self.youpaipdemoBarBgV) {
  571. [self youpaifhideDemoBar];
  572. }
  573. }
  574. /// 发送消息按钮点击事件
  575. - (void)youpaifsendMessageBtnClick{
  576. [self youpaifsendMessageBecomeFirstResponder];
  577. }
  578. /// 喇叭
  579. - (void)youpaifvoice:(BOOL)isOpen{
  580. if (isOpen) {
  581. [self.youpaipagoraKit muteLocalAudioStream:YES];
  582. }else{
  583. [self.youpaipagoraKit muteLocalAudioStream:NO];
  584. }
  585. }
  586. /// 查看在线人员列表
  587. - (void)youpaifliveMemberCountBtnClick{
  588. YOUPAILZLiveMemberListVC *memberVc = [[YOUPAILZLiveMemberListVC alloc] init];
  589. memberVc.youpaiplive_id = self.youpaipliveModel.youpaiplive_id;
  590. memberVc.isTouchDismiss = YES;
  591. memberVc.youpaipisAnchor = YES;
  592. @weakify(self);
  593. [memberVc setSelectedMemberBlock:^(YOUPAILZLiveMemberModel * _Nonnull member) {
  594. @strongify(self);
  595. [self youpaifshowUserInfoWithUserId:member.youpaipid];
  596. }];
  597. [self TFPresentVC:memberVc completion:^{}];
  598. }
  599. /// 切换摄像头
  600. - (void)youpaifchangeCamera{
  601. [self.youpaipmCamera changeCameraInputDeviceisFront:!self.youpaipmCamera.isFrontCamera];
  602. [self.youpaipagoraKit switchCamera];
  603. [[FUManager shareManager] onCameraChange];
  604. }
  605. /// 连麦事件
  606. - (void)youpaifforwardChannel{
  607. AgoraChannelMediaRelayConfiguration *config = [[AgoraChannelMediaRelayConfiguration alloc] init];
  608. AgoraChannelMediaRelayInfo *fromRelayInfo = [[AgoraChannelMediaRelayInfo alloc] init];
  609. fromRelayInfo.channelName = self.youpaipliveModel.youpaiproomid;
  610. fromRelayInfo.uid = [self.youpaipliveModel.youpaipuser_info.youpaipuser_id integerValue];
  611. config.sourceInfo = fromRelayInfo;
  612. NSString *roomid = self.youpaipstartPKModel.youpaipto_roomid;
  613. if (roomid.length == 0) {
  614. roomid = self.youpaipstartPKModel.youpaipfrom_roomid;
  615. }
  616. [config setDestinationInfo:fromRelayInfo forChannelName:roomid];
  617. // [self.youpaipagoraKit startChannelMediaRelay:config];
  618. [self.youpaipagoraKit startOrUpdateChannelMediaRelay:config];
  619. UIButton *btn = nil;
  620. if (self.youpaipinviteType == LZLiveInviteTypePK) {
  621. btn = self.youpaippkBtn;
  622. }else{
  623. btn = self.youpaiplianmaiBtn;
  624. }
  625. btn.selected = YES;
  626. [btn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_close_pk_lianmai"] forState:UIControlStateNormal];
  627. [btn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_close_pk_lianmai"] forState:UIControlStateHighlighted];
  628. }
  629. /// 更多菜单点击
  630. - (void)youpaifmoreBtnClick{
  631. [self.youpaipmenuView youpaifshowAnimation];
  632. }
  633. // 连麦按钮点击事件
  634. - (void)youpaiflianmaiBtnClick:(UIButton *)sender{
  635. if (sender.isSelected == NO) {
  636. YOUPAILZLiveInviteVC *vc = [[YOUPAILZLiveInviteVC alloc] initWithType:LZLiveInviteTypeLianMai];
  637. @weakify(self);
  638. [vc setYoupaipinviteBlock:^(LZLiveInviteType type, YOUPAILZLiveInviteModel * _Nonnull model) {
  639. @strongify(self);
  640. [self youpaifrequestLianMaiOrPKWithType:type model:model];
  641. }];
  642. [self TFPresentViewController:vc presentSize:CGSizeMake(KScreenWidth, ScaleSize(343.0f)) direction:TFDirectionBottom completion:^{}];
  643. }else{
  644. @weakify(self);
  645. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"结束连麦" handler:^(LZAlertAction *action) {
  646. @strongify(self);
  647. [self youpaifhangupLianMaiOrPK];
  648. }];
  649. cancelAction.cornerRadius = 24.0f;
  650. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  651. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"继续连麦" handler:^(LZAlertAction *action) {
  652. }];
  653. confimAction.cornerRadius = 24.0f;
  654. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  655. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:@"当前处于连麦状态,是否确认结束连麦?" action:@[cancelAction,confimAction]];
  656. [self TFPresentVC:alert completion:^{}];
  657. }
  658. }
  659. /// 赠送礼物按钮点击事件
  660. - (void)youpaifgiftBtnClick{
  661. YOUPAILZCommonGiftView *view = [YOUPAILZCommonGiftView new];
  662. view.isTouchDismiss = YES;
  663. view.youpaipisAnchor = YES;
  664. [view setYoupaiplzgiftblock:^(YOUPAILCGiftModel * _Nonnull model, NSInteger count,NSString*categoryID) {
  665. [ZCHUDHelper showTitle:@"你在直播中,暂时不可以送礼物"];
  666. }];
  667. [self TFPresentVC:view completion:^{
  668. }];
  669. }
  670. // pk按钮点击事件
  671. - (void)youpaifpkBtnClick:(UIButton *)sender{
  672. if (sender.isSelected == NO) {
  673. YOUPAILZLiveInviteVC *vc = [[YOUPAILZLiveInviteVC alloc] initWithType:LZLiveInviteTypePK];
  674. @weakify(self);
  675. [vc setYoupaipinviteBlock:^(LZLiveInviteType type, YOUPAILZLiveInviteModel * _Nonnull model) {
  676. @strongify(self);
  677. [self youpaifrequestLianMaiOrPKWithType:type model:model];
  678. }];
  679. [self TFPresentViewController:vc presentSize:CGSizeMake(KScreenWidth, ScaleSize(343.0f)) direction:TFDirectionBottom completion:^{}];
  680. }else{
  681. NSString *cancelT = @"";
  682. NSString *confimT = @"";
  683. NSString *contentT = @"";
  684. if (self.youpaippkState == LZLivePKStatePK) {
  685. cancelT = @"结束PK";
  686. confimT = @"继续PK";
  687. contentT = @"当前处于PK状态,是否确认结束PK?";
  688. }else if(self.youpaippkState == LZLivePKStatePunishment){
  689. cancelT = @"断开PK";
  690. confimT = @"继续PK";
  691. contentT = @"当前处于惩罚时间,是否断开PK?";
  692. }else if(self.youpaippkState == LZLivePKStateEnd){
  693. cancelT = @"结束PK";
  694. confimT = @"继续PK";
  695. contentT = @"当前处于PK连线状态,是否确认结束PK?";
  696. }
  697. @weakify(self);
  698. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:cancelT handler:^(LZAlertAction *action) {
  699. @strongify(self);
  700. [self youpaifhangupLianMaiOrPK];
  701. }];
  702. cancelAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[HexColorFromRGB(0x9F9DA5),HexColorFromRGB(0x9F9DA5)] ByGradientType:GradientLeftToRight]];;
  703. cancelAction.cornerRadius = 24.0f;
  704. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:confimT handler:^(LZAlertAction *action) {
  705. }];
  706. confimAction.cornerRadius = 24.0f;
  707. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  708. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:contentT action:@[cancelAction,confimAction]];
  709. [self TFPresentVC:alert completion:^{}];
  710. }
  711. }
  712. /// 重新pk事件
  713. - (void)youpaifrePKBtnClick{
  714. NSString *roomid = self.youpaipstartPKModel.youpaipto_roomid;
  715. if (roomid.length == 0) {
  716. roomid = self.youpaipstartPKModel.youpaipfrom_roomid;
  717. }
  718. [LCHttpHelper requestWithURLString:ReStartPK parameters:@{@"room_id":roomid} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  719. NSDictionary* dict = (NSDictionary*)responseObject;
  720. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  721. if (code == 0) {
  722. }else{
  723. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  724. }
  725. } failure:^(NSError *error) {
  726. [ZCHUDHelper showTitle:error.localizedDescription];
  727. }];
  728. }
  729. /// 获取用户信息
  730. - (void)youpaifshowUserInfoClick:(UIButton *)sender{
  731. [self youpaifshowUserInfoWithUserId:[NSString stringWithFormat:@"%@",@(sender.tag)]];
  732. }
  733. /// 隐藏demoBar
  734. - (void)youpaifhideDemoBar{
  735. self.youpaipdemoBar.frame = CGRectMake(0, KScreenHeight - SafeHeight - 182.0f , KScreenWidth, 182.0f);
  736. [UIView animateWithDuration:0.25f animations:^{
  737. self.youpaipdemoBar.frame = CGRectMake(0, KScreenHeight , KScreenWidth, 182.0f);
  738. } completion:^(BOOL finished) {
  739. self.youpaipdemoBarBgV.hidden = YES;
  740. }];
  741. }
  742. /// 显示demoBar
  743. - (void)youpaifshowDemoBar{
  744. [self.view bringSubviewToFront:self.youpaipdemoBarBgV];
  745. self.youpaipdemoBarBgV.hidden = NO;
  746. self.youpaipdemoBar.frame = CGRectMake(0, KScreenHeight , KScreenWidth, 182.0f);
  747. [UIView animateWithDuration:0.25f animations:^{
  748. self.youpaipdemoBar.frame = CGRectMake(0, KScreenHeight - SafeHeight - 182.0f , KScreenWidth, 182.0f);
  749. }];
  750. }
  751. #pragma mark - SDCycleScrollViewDelegate
  752. //- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
  753. //
  754. //}
  755. - (Class)customCollectionViewCellClassForCycleScrollView:(SDCycleScrollView *)view{
  756. return [YOUPAILZLiveBoardCycleViewCell class];
  757. }
  758. - (void)setupCustomCell:(UICollectionViewCell *)cell forIndex:(NSInteger)index cycleScrollView:(SDCycleScrollView *)view{
  759. YOUPAILZLiveBoardCycleViewCell *boardCell = (YOUPAILZLiveBoardCycleViewCell *)cell;
  760. NSString *type = view.imageURLStringsGroup[index];
  761. [boardCell youpaifreloadWithModel:[self.youpaipliveModel.youpaipanchor_rank_info valueForKey:type] type:type];
  762. @weakify(self);
  763. [boardCell setYoupaipclickBlock:^{
  764. @strongify(self);
  765. YOUPAILZLiveAnchorHotWindow *memberVc = [[YOUPAILZLiveAnchorHotWindow alloc] init];
  766. memberVc.youpaiplive_id = self.youpaipliveModel.youpaiplive_id;
  767. memberVc.isTouchDismiss = YES;
  768. memberVc.youpaipisAnchor = YES;
  769. [memberVc setSelectedMemberBlock:^(YOUPAILZLiveMemberModel * _Nonnull member) {
  770. @strongify(self);
  771. [self youpaifshowUserInfoWithUserId:member.youpaipid];
  772. }];
  773. [self TFPresentVC:memberVc completion:^{}];
  774. }];
  775. }
  776. #pragma mark - FUAPIDemoBarDelegate
  777. -(void)restDefaultValue:(int)type{
  778. if (type == 1) {//美肤
  779. [[FUManager shareManager] setBeautyDefaultParameters:FUBeautyModuleTypeSkin];
  780. }
  781. if (type == 2) {
  782. [[FUManager shareManager] setBeautyDefaultParameters:FUBeautyModuleTypeShape];
  783. }
  784. }
  785. /// 滤镜发生变化
  786. -(void)filterValueChange:(FUBeautyParam *)param{
  787. int youpaiphandle = [[FUManager shareManager] getHandleAboutType:FUNamaHandleTypeBeauty];
  788. [FURenderer itemSetParam:youpaiphandle withName:@"filter_name" value:[param.mParam lowercaseString]];
  789. [FURenderer itemSetParam:youpaiphandle withName:@"filter_level" value:@(param.mValue)]; //滤镜程度
  790. [FUManager shareManager].seletedFliter = param;
  791. }
  792. /// 美颜发生变化
  793. -(void)beautyParamValueChange:(FUBeautyParam *)param{
  794. if (_youpaipdemoBar.selBottomIndex == 3) {//风格栏
  795. if (param.beautyAllparams) {
  796. [[FUManager shareManager] setStyleBeautyParams:param.beautyAllparams];
  797. [FUManager shareManager].currentStyle = param;
  798. }else{// 点击无
  799. [FUManager shareManager].currentStyle = param;
  800. [[FUManager shareManager] loadFilter];
  801. }
  802. return;
  803. }
  804. if ([param.mParam isEqualToString:@"cheek_narrow"] || [param.mParam isEqualToString:@"cheek_small"]){//程度值 只去一半
  805. [[FUManager shareManager] setParamItemAboutType:FUNamaHandleTypeBeauty name:param.mParam value:param.mValue * 0.5];
  806. }else if([param.mParam isEqualToString:@"blur_level"]) {//磨皮 0~6
  807. [[FUManager shareManager] setParamItemAboutType:FUNamaHandleTypeBeauty name:param.mParam value:param.mValue * 6];
  808. }else{
  809. [[FUManager shareManager] setParamItemAboutType:FUNamaHandleTypeBeauty name:param.mParam value:param.mValue];
  810. }
  811. }
  812. #pragma mark - getter and setter
  813. - (FUAPIDemoBar*)youpaipdemoBar{
  814. if (!_youpaipdemoBar) {
  815. _youpaipdemoBar = [[FUAPIDemoBar alloc] init];
  816. _youpaipdemoBar.mDelegate = self;
  817. }
  818. return _youpaipdemoBar;
  819. }
  820. - (YOUPAILZAnchorMenuView *)youpaipmenuView{
  821. if (!_youpaipmenuView) {
  822. _youpaipmenuView = [[YOUPAILZAnchorMenuView alloc] initWithSupView:self.view];
  823. @weakify(self);
  824. // 隐藏聊天记录
  825. [_youpaipmenuView setYoupaiphideChatMessageBlock:^{
  826. @strongify(self);
  827. [self youpaifhiddenChatList];
  828. }];
  829. // // 更换字体大小
  830. // [_youpaipmenuView setYoupaipreplaceChatMessageFontSizeBlock:^{
  831. // @strongify(self);
  832. // self.youpaipliveModel.isMaxFont = !self.youpaipliveModel.isMaxFont;
  833. // [self youpaifreloadChatList];
  834. // }];
  835. // 静音
  836. [_youpaipmenuView setYoupaipcloseVoiceBlock:^(BOOL open) {
  837. @strongify(self);
  838. [self youpaifvoice:open];
  839. }];
  840. // 点击切换摄像头
  841. [_youpaipmenuView setYoupaipchangeCameraBlock:^{
  842. @strongify(self);
  843. [self youpaifchangeCamera];
  844. }];
  845. // 点击美颜
  846. [_youpaipmenuView setYoupaipbeautyBlock:^{
  847. @strongify(self);
  848. [self youpaifshowDemoBar];
  849. }];
  850. // 结束直播
  851. [_youpaipmenuView setYoupaipcloseBlock:^{
  852. @strongify(self);
  853. [self youpaifendLive];
  854. }];
  855. // 背景音乐
  856. [_youpaipmenuView setShowMusicBlock:^{
  857. @strongify(self);
  858. YOUPAILZLiveMusicListWindow *vc = [[YOUPAILZLiveMusicListWindow alloc] init];
  859. vc.youpaipcurrentMusic = self.currentMusic;
  860. vc.showLyric = self.youpaipmusicPlayerView.showLyric;
  861. vc.youpaipmusicList = self.youpaipmusicList;
  862. // vc.youpaipmusicPlayState = self.youpaipmusicPlayState;
  863. // 播放音乐
  864. [vc setYoupaipplayMusicBlock:^(YOUPAILZMusicListItemModel * _Nonnull model) {
  865. @strongify(self);
  866. if (![model.youpaipsongCode isEqual: self.currentMusic.youpaipsongCode]) {
  867. self.currentMusic = model;
  868. [self youpaifloadMusicInfoWithModel:self.currentMusic];
  869. }
  870. }];
  871. // 暂停or播放
  872. [vc setYoupaipsuspendMusicBlock:^{
  873. @strongify(self);
  874. // if (self.youpaipmusicPlayState == AgoraAudioMixingStatePlaying) {
  875. // [self.youpaipagoraKit pauseAudioMixing];
  876. // }else{
  877. // [self.youpaipagoraKit resumeAudioMixing];
  878. // }
  879. }];
  880. // 下一首
  881. [vc setYoupaipnextMusicBlock:^{
  882. @strongify(self);
  883. [self youpaifnextMusic];
  884. }];
  885. // 是否展示歌词
  886. [vc setShowLyricBlock:^(BOOL show) {
  887. @strongify(self);
  888. self.youpaipmusicPlayerView.showLyric = show;
  889. }];
  890. // 退出
  891. [vc setYoupaipcloseBlock:^{
  892. @strongify(self);
  893. self.youpaipmusicPlayerView.hidden = YES;
  894. [self.youpaipagoraKit stopAudioMixing];
  895. }];
  896. ZCBaseNavigationVC *nav = [[ZCBaseNavigationVC alloc] initWithRootViewController:vc];
  897. [self TFPresentViewController:nav presentSize:CGSizeMake(KScreenWidth, KScreenHeight * 0.6f) direction:TFDirectionBottom completion:^{}];
  898. }];
  899. // 成员管理
  900. [_youpaipmenuView setShowMemberManage:^{
  901. @strongify(self);
  902. [self youpaifshowMemberManageAlert];
  903. }];
  904. }
  905. return _youpaipmenuView;
  906. }
  907. /// 下一首音乐
  908. - (void)youpaifnextMusic{
  909. if (self.youpaipmusicList.count == 0) {
  910. return;
  911. }
  912. if ([self.youpaipmusicList containsObject:self.currentMusic]) {
  913. NSInteger index = [self.youpaipmusicList indexOfObject:self.currentMusic];
  914. if (index + 1 < self.youpaipmusicList.count) {
  915. self.currentMusic = self.youpaipmusicList[index + 1];
  916. [self youpaifloadMusicInfoWithModel:self.currentMusic];
  917. }else{
  918. self.currentMusic = self.youpaipmusicList[0];
  919. [self youpaifloadMusicInfoWithModel:self.currentMusic];
  920. }
  921. }else{
  922. self.currentMusic = self.youpaipmusicList[0];
  923. [self youpaifloadMusicInfoWithModel:self.currentMusic];
  924. }
  925. }
  926. /// 获取音乐信息
  927. - (void)youpaifloadMusicInfoWithModel:(YOUPAILZMusicListItemModel *)model{
  928. /* [[NSNotificationCenter defaultCenter] postNotificationName:@"CurrentMusicChangeNotification" object:model userInfo:nil];
  929. @weakify(self);
  930. [LCHttpHelper requestWithURLString:MusicInfo parameters:@{@"musicId":model.youpaipsongCode} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  931. @strongify(self);
  932. NSDictionary* dict = (NSDictionary*)responseObject;
  933. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  934. if (code == 0) {
  935. NSLog(@"-----%@",[dict objectForKey:@"data"]);
  936. YOUPAILZMusicModel *youpaipmusicModel = [YOUPAILZMusicModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
  937. youpaipmusicModel.youpaipmusicName = model.youpaipname;
  938. if (model.youpaipposter.length != 0) {
  939. youpaipmusicModel.youpaipcover = model.youpaipposter;
  940. }
  941. if (youpaipmusicModel.youpaipdynamicLyricUrl.length != 0) {
  942. dispatch_queue_t queue = dispatch_get_global_queue(0, 0);
  943. dispatch_async(queue, ^{
  944. NSString *lrcStr = [NSString stringWithContentsOfURL:[NSURL URLWithString:youpaipmusicModel.youpaipdynamicLyricUrl] encoding:NSUTF8StringEncoding error:nil];
  945. [youpaipmusicModel youpaifparseLrc:lrcStr];
  946. dispatch_async(dispatch_get_main_queue(), ^{
  947. @strongify(self);
  948. self.youpaipmusicPlayerView.hidden = NO;
  949. [self.youpaipmusicPlayerView youpaifreloadMusicModel:youpaipmusicModel];
  950. [self youpaifstartPlayMusicWithPath:youpaipmusicModel.youpaipfileUrl];
  951. });
  952. });
  953. }else{
  954. self.youpaipmusicPlayerView.hidden = NO;
  955. youpaipmusicModel.youpaipwordArray = @[youpaipmusicModel.youpaipmusicName,@""].mutableCopy;
  956. [self.youpaipmusicPlayerView youpaifreloadMusicModel:youpaipmusicModel];
  957. [self youpaifstartPlayMusicWithPath:youpaipmusicModel.youpaipfileUrl];
  958. }
  959. }else{
  960. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  961. }
  962. } failure:^(NSError *error) {
  963. [ZCHUDHelper showTitle:error.localizedDescription];
  964. }]; */
  965. }
  966. /// 播放音乐
  967. - (void)youpaifstartPlayMusicWithPath:(NSString *)path{
  968. // 设置是否只在本地播放音乐文件。true 表示只有本地用户能听到音乐;false 表示本地用户和远端用户都能听到音乐。
  969. BOOL youpaiploopback = NO;
  970. // 设置是否用音乐文件替换麦克风采集的音频。true 表示用户只能听到音乐;false 表示用户可以听到音乐和麦克风采集的音频。
  971. BOOL youpaipreplace = NO;
  972. // 设置音乐文件的播放次数。1 表示播放 1 次。
  973. NSInteger cycle = 1;
  974. // [self.youpaipagoraKit startAudioMixing:path loopback:youpaiploopback replace:youpaipreplace cycle:cycle];
  975. // 调节音乐文件的播放音量
  976. [self.youpaipagoraKit adjustAudioMixingVolume:50];
  977. }
  978. /// 设置用户角色
  979. - (AgoraClientRole)youpaifclientRole{
  980. return AgoraClientRoleBroadcaster;
  981. }
  982. /// 结束直播
  983. - (void)youpaifendLive{
  984. @weakify(self);
  985. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  986. }];
  987. cancelAction.cornerRadius = 24.0f;
  988. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  989. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确认" handler:^(LZAlertAction *action) {
  990. @strongify(self);
  991. [self youpaifrequestCloseLiveData];
  992. }];
  993. confimAction.cornerRadius = 24.0f;
  994. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  995. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:@"是否要结束直播" action:@[cancelAction,confimAction]];
  996. alert.contentTextAlignment = NSTextAlignmentCenter;
  997. [self TFPresentVC:alert completion:^{}];
  998. }
  999. bool youpaipisShowRePKAlert = NO;
  1000. /// 被连麦者获取连麦或pk信息
  1001. - (void)youpaifrequestObtainInteractWithPkId:(NSString *)pkId type:(LZLiveInviteType)type{
  1002. @weakify(self);
  1003. [LCHttpHelper requestWithURLString:ObtainInteract parameters:@{@"pk_id":pkId} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  1004. @strongify(self);
  1005. NSDictionary* dict = (NSDictionary*)responseObject;
  1006. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1007. if (code == 0) {
  1008. YOUPAILZLiveStartPKModel *model = [YOUPAILZLiveStartPKModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
  1009. if (self.youpaipstartPKModel != nil && ![self.youpaipstartPKModel.youpaippk_id isEqual:model.youpaippk_id]) {
  1010. if (youpaipisShowRePKAlert == NO) {
  1011. youpaipisShowRePKAlert = YES;
  1012. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"拒绝" handler:^(LZAlertAction *action) {
  1013. youpaipisShowRePKAlert = NO;
  1014. [LCHttpHelper requestWithURLString:ReFusePK parameters:@{@"pk_id":model.youpaippk_id} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  1015. NSDictionary* dict = (NSDictionary*)responseObject;
  1016. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1017. if (code == 0) {
  1018. }else{
  1019. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  1020. }
  1021. } failure:^(NSError *error) {
  1022. [ZCHUDHelper showTitle:error.localizedDescription];
  1023. }];
  1024. }];
  1025. cancelAction.cornerRadius = 24.0f;
  1026. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  1027. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"接受" handler:^(LZAlertAction *action) {
  1028. @strongify(self);
  1029. youpaipisShowRePKAlert = NO;
  1030. NSDictionary *params = @{@"pk_id":self.youpaipstartPKModel.youpaippk_id,@"new_pk_id":model.youpaippk_id};
  1031. self.youpaipstartPKModel = model;
  1032. [LCHttpHelper requestWithURLString:ReceiveRestartPK parameters:params needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  1033. NSDictionary* dict = (NSDictionary*)responseObject;
  1034. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1035. if (code == 0) {
  1036. }else{
  1037. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  1038. }
  1039. } failure:^(NSError *error) {
  1040. [ZCHUDHelper showTitle:error.localizedDescription];
  1041. }];
  1042. }];
  1043. confimAction.cornerRadius = 24.0f;
  1044. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  1045. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:@"对方邀请您重新PK" action:@[cancelAction,confimAction]];
  1046. alert.contentTextAlignment = NSTextAlignmentCenter;
  1047. [self TFPresentVC:alert completion:^{}];
  1048. }
  1049. }else{
  1050. YOUPAILZLiveCallWindow *vc = [[YOUPAILZLiveCallWindow alloc] initWithState:LZLiveInviteStateAnswer type:type model:model];
  1051. vc.isTouchDismiss = NO;
  1052. [vc setYoupaipstartConnectBlock:^(YOUPAILZLiveStartPKModel * _Nonnull model) {
  1053. @strongify(self);
  1054. self.youpaipstartPKModel = model;
  1055. self.youpaipinviteType = type;
  1056. [self youpaifforwardChannel];
  1057. }];
  1058. [self TFPresentVC:vc completion:^{}];
  1059. }
  1060. }else{
  1061. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  1062. }
  1063. } failure:^(NSError *error) {
  1064. [ZCHUDHelper showTitle:error.localizedDescription];
  1065. }];
  1066. }
  1067. /// 开始连麦/PK
  1068. - (void)youpaifrequestLianMaiOrPKWithType:(LZLiveInviteType)type model:(YOUPAILZLiveInviteModel *)model{
  1069. NSDictionary *params = @{
  1070. @"room_id":model.youpaiproom_id,
  1071. @"type":type == LZLiveInviteTypePK ? @"pk" : @"lianmai"
  1072. };
  1073. @weakify(self);
  1074. [LCHttpHelper requestWithURLString:StartInteract parameters:params needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  1075. @strongify(self);
  1076. NSDictionary* dict = (NSDictionary*)responseObject;
  1077. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1078. if (code == 0) {
  1079. YOUPAILZLiveStartPKModel *model = [YOUPAILZLiveStartPKModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
  1080. self.youpaipstartPKModel = model;
  1081. YOUPAILZLiveCallWindow *vc = [[YOUPAILZLiveCallWindow alloc] initWithState:LZLiveInviteStateCall type:type model:model];
  1082. vc.isTouchDismiss = NO;
  1083. [self TFPresentVC:vc completion:^{}];
  1084. }else{
  1085. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  1086. }
  1087. } failure:^(NSError *error) {
  1088. [ZCHUDHelper showTitle:error.localizedDescription];
  1089. }];
  1090. }
  1091. /// 挂断连麦/PK
  1092. - (void)youpaifhangupLianMaiOrPK{
  1093. NSDictionary *params = @{
  1094. @"pk_id":self.youpaipstartPKModel.youpaippk_id,
  1095. @"event":@"hangup"
  1096. };
  1097. NSString *api = OperateFrom;
  1098. if (self.youpaipstartPKModel.youpaipfrom_roomid.length != 0) {
  1099. api = OperateTo;
  1100. }
  1101. [LCHttpHelper requestWithURLString:api parameters:params needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  1102. NSDictionary* dict = (NSDictionary*)responseObject;
  1103. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1104. if (code == 0) {
  1105. }else{
  1106. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  1107. }
  1108. } failure:^(NSError *error) {
  1109. [ZCHUDHelper showTitle:error.localizedDescription];
  1110. }];
  1111. }
  1112. - (void)youpaifrequestCloseLiveData{
  1113. @weakify(self);
  1114. [LCHttpHelper requestWithURLString:CloseLive parameters:@{@"id":self.youpaipliveModel.youpaiplive_id} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  1115. @strongify(self);
  1116. NSDictionary* dict = (NSDictionary*)responseObject;
  1117. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1118. if (code == 0) {
  1119. [LCSaveData saveIsVideo:NO];
  1120. YOUPAILZLiveCloseModel *model = [YOUPAILZLiveCloseModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
  1121. [self youpaifleaveChannel];
  1122. YOUPAILZAnchorLiveCloseVC *vc = [[YOUPAILZAnchorLiveCloseVC alloc] init];
  1123. vc.youpaipmodel = model;
  1124. vc.hidesBottomBarWhenPushed = YES;
  1125. NSArray *vcs = self.navigationController.viewControllers;
  1126. NSMutableArray <UIViewController *>*nVcs = [NSMutableArray array];
  1127. BOOL youpaipisContainsCloseVC = NO;
  1128. for (UIViewController *fvc in vcs) {
  1129. if ([fvc isKindOfClass:[YOUPAILZAnchorLiveCloseVC class]]) {
  1130. youpaipisContainsCloseVC = YES;
  1131. }
  1132. }
  1133. if (!youpaipisContainsCloseVC) {
  1134. for (UIViewController *fvc in vcs) {
  1135. if (!([fvc isKindOfClass:[YOUPAILZLiveAnchorVC class]] || [fvc isKindOfClass:[YOUPAILZAnchorLiveCloseVC class]])) {
  1136. [nVcs addObject:fvc];
  1137. }
  1138. }
  1139. [nVcs addObject:vc];
  1140. [self.navigationController setViewControllers:nVcs.copy animated:YES];
  1141. }
  1142. }else{
  1143. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  1144. }
  1145. } failure:^(NSError *error) {
  1146. [ZCHUDHelper showTitle:error.localizedDescription];
  1147. }];
  1148. }
  1149. /// 顶部榜单相关函数
  1150. - (void)youpaifeditBtnCountWithCount:(NSInteger)count{
  1151. if (count >= self.youpaipmemberBtns.count) {
  1152. [self youpaifaddBtnWithCount:count - self.youpaipmemberBtns.count];
  1153. }else{
  1154. [self youpaifdeleteBtnWithCount:self.youpaipmemberBtns.count - count];
  1155. }
  1156. }
  1157. - (void)youpaifdeleteBtnWithCount:(NSInteger)count{
  1158. if (count != 0) {
  1159. for (NSInteger i = 0; i < count; i ++) {
  1160. YOUPAILZLiveMemberButton *btn = self.youpaipmemberBtns.lastObject;
  1161. [self.youpaipmemberBtns removeLastObject];
  1162. [btn removeFromSuperview];
  1163. }
  1164. }
  1165. }
  1166. - (void)youpaifaddBtnWithCount:(NSInteger)count{
  1167. for (NSInteger i = 0; i < count; i ++) {
  1168. [self youpaifcreateBtn];
  1169. }
  1170. }
  1171. - (void)youpaifcreateBtn{
  1172. YOUPAILZLiveMemberButton *btn = [[YOUPAILZLiveMemberButton alloc] init];
  1173. btn.imageView.contentMode = UIViewContentModeScaleAspectFill;
  1174. btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
  1175. btn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
  1176. // btn.layer.cornerRadius = 3.0f;
  1177. // btn.clipsToBounds = YES;
  1178. [self.youpaiprankBgV addSubview:btn];
  1179. [self.youpaipmemberBtns addObject:btn];
  1180. }
  1181. - (NSMutableArray<YOUPAILZLiveMemberButton *> *)youpaipmemberBtns{
  1182. if (!_youpaipmemberBtns) {
  1183. _youpaipmemberBtns = [NSMutableArray array];
  1184. }
  1185. return _youpaipmemberBtns;
  1186. }
  1187. - (NSMutableArray<YOUPAILZMusicListItemModel *> *)youpaipmusicList{
  1188. if (!_youpaipmusicList) {
  1189. _youpaipmusicList = [NSMutableArray array];
  1190. }
  1191. return _youpaipmusicList;
  1192. }
  1193. @end