BGLiveServiceController.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. //
  2. // BGLiveServiceController.h
  3. // BugoLive
  4. //
  5. // Created by xfg on 16/11/23.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. // 直播业务层
  8. #import <UIKit/UIKit.h>
  9. #import "BGLiveUIViewController.h"
  10. #import "TCShowLiveView.h"
  11. #import "CurrentLiveInfo.h"
  12. #import "FinishLiveView.h"
  13. #import "BGFinishLiveView.h"
  14. #import "ManagerViewController.h"
  15. #import "GifImageView.h"
  16. #import "SLiveRedBagView.h"
  17. #import "SLiveReportView.h"
  18. #import "MessageView.h"
  19. #import "Plane1Controller.h"
  20. #import "Plane2Controller.h"
  21. #import "FerrariController.h"
  22. #import "LambohiniViewController.h"
  23. #import "RocketViewController.h"
  24. #import "AddFriendView.h"
  25. #import "PasteView.h"
  26. #import "SendGiftAnimateView.h"
  27. #import "SendGiftAnimateView2.h"
  28. #import "ContributionListViewController.h"
  29. #import "PluginCenterView.h"
  30. #import "AuctionItemdetailsViewController.h"
  31. #import "ConverDiamondsViewController.h"
  32. #import "ShareModel.h"
  33. #import "RechargeView.h"
  34. #import "MGLiveRechargeView.h"//充值界面
  35. #import "ExchangeView.h"
  36. #import "OtherChangeView.h"
  37. #import "OtherRoomBitGiftView.h"
  38. #import "SHomePageVC.h"
  39. #import "SLiveHeadInfoView.h"
  40. #import "SLiveReportView.h"
  41. #import "BGLiveServiceViewModel.h"
  42. #import "SManageFriendVC.h"
  43. #import "CarAnimationPlayer.h"
  44. //#import "CYLiveNotice.h"
  45. #import "SVGAAnimate.h"
  46. #import "WinTipView.h"
  47. @class WardPopView;
  48. @class WardOpenView;
  49. typedef void (^FWLiveGetVideoCompletion)(CurrentLiveInfo *liveInfo);
  50. typedef NS_ENUM(NSInteger, SmallGiftAnimateIndex)
  51. {
  52. SmallGiftAnimateIndex_1 = 1, // 底下的那个礼物动画视图(默认优先显示)
  53. SmallGiftAnimateIndex_2 = 2, // 上面的那个礼物动画视图
  54. };
  55. @class BGLiveServiceController;
  56. @protocol FWLiveServiceControllerDelegate <NSObject>
  57. @required
  58. /**
  59. 关闭直播间
  60. @param isDirectCloseLive 该参数针对主播、观众,表示是否直播关闭直播,而不显示结束界面
  61. @param isHostShowAlert 该参数针对主播,表示主播是否需要弹出“您当前正在直播,是否退出直播?”,正常情况都需要弹出这个,不需要弹出的情况:1、当前直播被后台系统关闭了的情况 2、SDK结束了直播
  62. */
  63. - (void)clickCloseLive:(BOOL)isDirectCloseLive isHostShowAlert:(BOOL)isHostShowAlert;
  64. /**
  65. 结束界面点击“返回首页”
  66. @param liveServiceController self
  67. */
  68. - (void)finishViewClose:(BGLiveServiceController *)liveServiceController;
  69. //直播间滑动
  70. - (void)protocolDidScrollView:(BGTLiveScrollView *)scrollView isRefreshLive:(BOOL)isRefresh;
  71. -(void)protocolGetVideoWithRoomID:(NSString *)roomID;
  72. @optional
  73. /**
  74. 连麦、关闭连麦
  75. @param liveServiceController self
  76. */
  77. - (void)openOrCloseMike:(BGLiveServiceController *)liveServiceController;
  78. /**
  79. 收到自定义C2C消息
  80. @param msg 实现AVIMMsgAble协议的msg
  81. */
  82. - (void)recvCustomC2C:(id<AVIMMsgAble>)msg;
  83. /**
  84. 收到自定义的Group消息
  85. @param msg 实现AVIMMsgAble协议的msg
  86. */
  87. - (void)recvCustomGroup:(id<AVIMMsgAble>)msg;
  88. /**
  89. 请求完接口后,刷新直播间相关信息
  90. @param liveItem 视频Item
  91. @param liveInfo get_video2接口获取下来的数据实体
  92. */
  93. - (void)refreshCurrentLiveItem:(id<FWShowLiveRoomAble>)liveItem liveInfo:(CurrentLiveInfo *)liveInfo;
  94. - (void)refreshVoice:(id<FWShowLiveRoomAble>)liveItem liveInfo:(CustomMessageModel *)customMessageModel;
  95. - (void)refreshUserListVoice;
  96. - (void)closeVoiceRoom;
  97. /**
  98. 点击飞屏模式,切换直播间
  99. */
  100. - (void)switchLiveRoom;
  101. //接收到表情
  102. - (void)recvEmoji:(CustomMessageModel *)model;
  103. //点击语音房间管理
  104. - (void)clickRoomManage;
  105. @end
  106. @interface BGLiveServiceController : BGBaseViewController<FWIMMsgListener,TCShowLiveViewServiceDelegate,TCShowLiveTopViewDelegate,TCShowLiveMessageViewDelegate,SLiveHeadInfoViewDelegate,RedBagViewDelegate,liveReportViewDelegate,CustomMessageModelDelegate,GifImageViewDelegate,MessageViewDelegate,Plane1ControllerDelegate,Plane2ControllerDelegate,FerrariControllerDelegate,LambohiniViewControllerDelegate,RocketViewControllerDelegate,addFriendDelegate,PasteViewDelegate,PluginCenterViewDelegate,RechargeViewDelegate,ExchangeViewDelegate,OtherChangeViewDelegate,FWLiveUIViewControllerServeiceDelegate,SVGAViewDelegate>
  107. {
  108. @protected
  109. __weak id<FWShowLiveRoomAble> _liveItem; // 开启、观看直播传入的实体
  110. id<FWLiveControllerAble> _liveController; // 当前SDK控制类
  111. UIButton *_closeBtn; // 关闭按钮
  112. SLiveHeadInfoView *_informationView; // 用户详情页
  113. AddFriendView *_addFView; // 加好友的View
  114. PasteView *_PView;
  115. NSTimer *_heartTimer; // 主播心跳监听
  116. NSString *_privateShareString;
  117. NSString *_tipoffUserId; // 被举报的用户ID
  118. // 礼物相关
  119. __weak BGIMMsgHandler *_iMMsgHandler; // IM处理单例
  120. __weak AddGiftRunLoop *_addGiftRunLoopRef; // 添加礼物处理线程的引用
  121. __weak GetGiftRunLoop *_getGiftRunLoopRef; // 获取礼物处理线程的引用
  122. NSMutableArray *_giftMessageMArray; // 礼物队列
  123. NSMutableDictionary *_giftMessageMDict; // 礼物队列(主要用来删除和取当前需要显示的数量)
  124. NSMutableArray *_giftMessageViewMArray; // 礼物视图队列
  125. NSMutableArray *_gifAnimateArray; // gif动画队列
  126. NSTimer *_giftLoopTimer; // 后台定时
  127. NSInteger _refreshIMMsgCount;
  128. NSInteger _currentBigGiftState; // 当前大型礼物播放状态 1:播放中 0:闲置状态
  129. NSString *_privateKeyString; // 私密的key
  130. CustomMessageModel *_ohterRoomBitGiftModel;
  131. //座驾
  132. CarAnimationPlayer *_aCYCarView;
  133. NSMutableArray *_aCYCarViewwArray; // 座驾入视图队列
  134. BOOL _aCYCarViewwShowing; // 座驾是否正在显示 高级别观众进入视图
  135. WardPopView *_wardPopView;
  136. WardOpenView *_wardOpenView;
  137. }
  138. @property (nonatomic, weak) id<FWLiveServiceControllerDelegate> delegate;
  139. // 直播UI层
  140. @property (nonatomic, strong) BGLiveUIViewController *liveUIViewController;
  141. // 当前直播实体
  142. @property (nonatomic, strong) CurrentLiveInfo *currentLiveInfo;
  143. // 关闭按钮
  144. @property (nonatomic, strong) UIButton *closeBtn;
  145. // 主播离开提示
  146. @property (nonatomic, strong) UILabel *anchorLeaveTipLabel;
  147. // 当前主播的印票数
  148. @property (nonatomic, assign) NSInteger voteNumber;
  149. // 是否主播
  150. @property (nonatomic, assign) BOOL isHost;
  151. // 房间ID
  152. @property (nonatomic, copy) NSString *roomIDStr;
  153. // 底下的那个礼物动画视图(默认优先显示)
  154. @property (nonatomic, strong) SendGiftAnimateView *sendGiftAnimateView1;
  155. // 上面的那个礼物动画视图
  156. @property (nonatomic, strong) SendGiftAnimateView2 *sendGiftAnimateView2;
  157. // 弹幕
  158. // 弹幕消息视图队列
  159. @property (nonatomic, strong) NSMutableArray *barrageViewArray;
  160. // 是否正在显示 弹幕(底下的弹幕)
  161. @property (nonatomic, assign) BOOL barrageViewShowing1;
  162. // 是否正在显示 弹幕(上面的弹幕)
  163. @property (nonatomic, assign) BOOL barrageViewShowing2;
  164. // 是否开启了录制
  165. @property (nonatomic, assign) BOOL isRecord;
  166. // 高级别观众进入
  167. @property (nonatomic, strong) AudienceEnteringTipView *aETView;
  168. // 高级别观众进入视图队列
  169. @property (nonatomic, strong) NSMutableArray *aETViewArray;
  170. // 是否正在显示 高级别观众进入视图
  171. @property (nonatomic, assign) BOOL aETViewShowing;
  172. // 中奖提示视图
  173. @property (nonatomic, strong) WinTipView *winTipView;
  174. // 中奖提示视图队列
  175. @property (nonatomic, strong) NSMutableArray *winTipViewArray;
  176. // 中奖正在显示开通提示
  177. @property (nonatomic, assign) BOOL winTipViewShowing;
  178. // 是否关注了主播
  179. @property (nonatomic, assign) BOOL isFollowAnchor;
  180. // 举报界面
  181. @property (nonatomic, strong) SLiveReportView *liveReportV;
  182. // 创建插件中心
  183. @property (nonatomic, strong) PluginCenterView *pluginCenterView;
  184. // 插件中心透明背景
  185. @property (nonatomic, strong) UIView *pluginCenterBgView;
  186. // 游戏id(游戏轮数id)
  187. @property (nonatomic, assign) NSInteger game_log_id;
  188. // 根据功能插件个数判断高度(游戏或功能)
  189. @property (nonatomic, assign) NSInteger gameOrFeatures;
  190. //// 直播间竞拍相关控制类
  191. //@property (nonatomic, strong) AuctionTool *auctionTool;
  192. // 直播间是否第一次加载视频
  193. @property (nonatomic, assign) BOOL IsFirstLoadVedio;
  194. // 充值页面
  195. @property (nonatomic, strong) RechargeView *rechargeView;
  196. @property (nonatomic, strong) ExchangeView *exchangeView;
  197. @property (nonatomic, strong) OtherChangeView *otherChangeView;
  198. //充值界面
  199. @property(nonatomic, strong) MGLiveRechargeView *mgRechargeView;
  200. // 飞屏模式
  201. // 其他房间发送的大型礼物动画队列
  202. @property (nonatomic, strong) NSMutableArray *otherRoomBitGiftArray;
  203. // 其他房间大型礼物播放状态(飞屏模式)
  204. @property (nonatomic, assign) NSInteger currentOtherRoomBigGiftState;
  205. // 飞屏展示
  206. @property (nonatomic, strong) OtherRoomBitGiftView *otherRoomBitGiftView;
  207. @property (nonatomic, strong) BGFinishLiveView *finishLiveView;
  208. @property(nonatomic, strong) MGGlobalVipView *globalView;//广播视图
  209. @property(nonatomic, copy) void (^clickCloseBlock)(BOOL isReresh);
  210. @property(nonatomic, assign) BOOL isVoice;
  211. /**
  212. 初始化房间信息等
  213. @param liveItem 房间信息
  214. @param liveController 直播VC
  215. @return self
  216. */
  217. - (instancetype)initWith:(id<FWShowLiveRoomAble>)liveItem liveController:(id<FWLiveControllerAble>)liveController;
  218. /**
  219. 请求完接口后,刷新直播间相关信息
  220. @param liveItem 视频Item
  221. @param liveInfo get_video2接口获取下来的数据实体
  222. */
  223. - (void)refreshLiveItem:(id<FWShowLiveRoomAble>)liveItem liveInfo:(CurrentLiveInfo *)liveInfo;
  224. /**
  225. 主播心跳监听
  226. */
  227. - (void)startLiveTimer;
  228. /**
  229. 主播进入房间状态回调
  230. @param parmMDict 传入的参数
  231. */
  232. - (void)getVideoState:(NSMutableDictionary *)parmMDict;
  233. /**
  234. 进入直播室成功后的相关业务:获得视频信息
  235. @param succ 成功回调
  236. @param failed 失败回调
  237. */
  238. - (void)getVideo:(FWLiveGetVideoCompletion)succ roomID:(NSString *)roomID failed:(FWErrorBlock)failed;
  239. /**
  240. 主播退出直播间
  241. @param succ 成功回调
  242. @param failed 失败回调
  243. */
  244. - (void)hostExitLive:(FWVoidBlock)succ failed:(FWErrorBlock)failed;
  245. /**
  246. 显示主播结束界面
  247. @param audience 观看数量
  248. @param vote 获得的印票数量
  249. @param hasDel 是否有删除按钮(该参数针对主播)
  250. */
  251. - (void)showHostFinishView:(NSString *)audience andVote:(NSString *)vote andHasDel:(BOOL)hasDel;
  252. - (void)getUserInfo:(UserModel *)userModel;
  253. /**
  254. 开始直播
  255. */
  256. - (void)startLive;
  257. /**
  258. 暂停直播
  259. */
  260. - (void)pauseLive;
  261. /**
  262. 重新开始直播
  263. */
  264. - (void)resumeLive;
  265. /**
  266. 结束直播
  267. */
  268. - (void)endLive;
  269. @end