Commit 3455844c by suolong

修改下mainviewcontroller的结构 对齐firefly

parent 187f7b27
......@@ -115,6 +115,10 @@
#define ROOM_CID_LIVE_ALERT 10090 // 接收到直播弹窗通知
#define ROOM_CID_WEBVIEW_PUSH 10092 // 推送webview弹窗
// 主播打开关闭麦克风socket
#define ROOM_CID_anchorDidCloseBeauty 20200
// 主播打开关闭麦克风socket
#define ROOM_CID_anchorDidCloseMic 20201
// 更新本场直播主题内容socket
#define ROOM_CID_LiveThemeDidChanged 20202
......@@ -126,5 +130,3 @@
......@@ -8,7 +8,7 @@
#import "FUSLiveMainViewController.h"
#import "FUSLiveManagerViewController.h"
#import "FUSLiveQuickChatSetAlertView.h"
#import "FUSLivePushPrepareView.h"
#import "FUSLiveHttpHelper.h"
#import "FUSSocketMessageDelegate.h"
......@@ -62,6 +62,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
@property (nonatomic, strong) UIButton *joinMicroBtn;
@property (nonatomic, strong) UIVisualEffectView *passwordBlurView;
/**
设置 Idle Time Disable 的Timer
*/
......@@ -131,7 +132,12 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
@property (nonatomic, assign) BOOL isClickCloseBtn;
// pk的时候,在画面下方显示的背景,防止画面还没显示出来一片黑的问题
//@property (nonatomic, strong) FUSPKBottomUserHeaderView *pkHeaderView;
@property (nonatomic, strong) FUSPKBottomUserHeaderView *pkHeaderView;
// 码率 Image View
@property (nonatomic, strong) UIImageView *bitrateImageView;
// 码率 Label
@property (nonatomic, strong) UILabel *bitrateLabel;
@property (nonatomic, strong) VELPictureInPictureController *pipController;
/// pic in pic 启动成功回调
......@@ -201,7 +207,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
self.autoStartPictureInPicture = FUSSwiftLiveHelper.shared.autoStartPictureInPicture;
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_liveRoomViewDidAppear object:nil];
// [self fus_setupPreloadingPlayers];
[self fus_setupPreloadingPlayers];
FUSSwiftLiveHelper.shared.oc_liveRoomLifeCycle = FUSLiveRoomVCLifeCycleAppear;
}
......@@ -581,10 +587,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
- (void)initLiveFunctionView {
_isClickCloseBtn = NO;
[self fus_initContentView];
// 防止多次创建 LiveFunctionView
if (_liveFunctionView) {
// [_liveFunctionView removeFromSuperview];
[self.contentView addSubview:_liveFunctionView];
return;
}
......@@ -599,9 +604,14 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
*/
- (void)initStreamView
{
if ([FUSLiveHelper shareInstance].liveRoomType == FUSRoomTypeLinkMic) {
[self fus_initContentView];
if (FUSLiveHelper.shareInstance.liveRTCData.rtcType == 1) {
if (FUSSwiftLiveHelper.shared.roomType == OBSRoom || FUSSwiftLiveHelper.shared.liveRoomType == FUSRoomTypeLinkMic) {
return;
}
}
switch (FUSLiveHelper.shareInstance.liveType) {
case FUSLiveTypeAnchor:
......@@ -643,14 +653,14 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
case FUSLiveTypeAudience:
{
// self.preRoomPlayView = [[YAStreamPlayView alloc] initWithFrame:self.scrollView.bounds];
// self.preRoomPlayView.hidden = YES;
// [self.scrollView addSubview:self.preRoomPlayView];
//
// self.nextRoomPlayView = [[YAStreamPlayView alloc] initWithFrame:self.scrollView.bounds];
// self.nextRoomPlayView.hidden = YES;
// self.nextRoomPlayView.y = self.scrollView.height * 2;
// [self.scrollView addSubview:self.nextRoomPlayView];
self.preRoomPlayView = [[FUSStreamPlayView alloc] initWithFrame:self.scrollView.bounds];
self.preRoomPlayView.hidden = YES;
[self.scrollView addSubview:self.preRoomPlayView];
self.nextRoomPlayView = [[FUSStreamPlayView alloc] initWithFrame:self.scrollView.bounds];
self.nextRoomPlayView.hidden = YES;
self.nextRoomPlayView.y = self.scrollView.height * 2;
[self.scrollView addSubview:self.nextRoomPlayView];
// 搭建观众端拉流 View
_streamView = [[FUSLiveStreamView alloc] initPlayViewWithFrame:self.contentView.bounds];
......@@ -658,10 +668,10 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[_streamView.playView fus_setVideoframeCallBackOpen:self.autoStartPictureInPicture forUid:self.streamView.playView.mainUID];
[_contentView addSubview:_streamView];
[FUSLiveHelper shareInstance].streamView = _streamView;
if (_streamURL) {
[_streamView.playView fus_playWithUID:[FUSLiveHelper shareInstance].roomInfoModel.roomId Url:_streamURL];
if (self.autoStartPictureInPicture) {
[self setupPictureInPicture];
}
_playView = _streamView.playView;
// 进入包房成功提示送礼view通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recieveJoinRoomSuccessNotification) name:FUSLiveUDKeys.fus_IS_JOIN_ROOM_SUCCESS object:nil];
......@@ -699,8 +709,94 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[weakSelf fus_startPush];
};
// OBS 推流成功回调
[pushPrepareView setObsPushSuccessHandler:^{
[weakSelf.backgroundImageView fus_setImageWithName:@"live_start_obs_bg"];
//
FUSSwiftLiveHelper.shared.roomType = OBSRoom;
FUSSwiftLiveHelper.shared.isStartedLive = YES;
// 开播成功
[weakSelf.pushPrepareView removeFromSuperview];
weakSelf.pushPrepareView = nil;
[FUSLiveHelper shareInstance].isInStartLiveView = NO;
// 移除推流 View
[weakSelf.pushView removeFromSuperview];
[weakSelf.pushView.captureHelper fus_stopStreamPush];
weakSelf.pushView = nil;
//因为正常直播的时候,是不会创建 playView 的
[weakSelf initPlayView];
[weakSelf fus_showLiveLoadingViewWithType:liveLoadingEntering];
//服务器启动推流
[FUSLiveHttpHelper fus_startPushStreamWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId] vdoid:[[[FUSLiveHelper shareInstance] streamModel] vdoid] livingWay:@"0" liveScope:[FUSLiveHelper shareInstance].roomScopeType success:^(NSDictionary *dict){
[FUSLiveHttpHelper fus_enterRoomWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId vdoid:[FUSLiveHelper shareInstance].streamModel.vdoid behaviorSrc:@"" password:@"" success:^(FUSRoomInfoModel *roomInfoModel,BOOL micMode, NSString *streamUrl, NSString *pkInfo) {
if (![roomInfoModel.roomId isEqualToString:[FUSLiveHelper shareInstance].roomInfoModel.roomId]) {
FUSLogInfo(@"不是当前包房");
return ;
}
// PKview更新
if (pkInfo.integerValue == 1) { //在pk中
// 审核下不显示PK
if(FUSConfig.sharedInstanced.devConfigs.appStatus) return;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[FUSSwiftLiveHelper.shared.pkHelper getRoomPKInfoWithRoomId:FUSSwiftLiveHelper.shared.roomInfoModel.roomId reconnect:1];
});
}
[weakSelf.playView fus_playWithUID:FUSSwiftLiveHelper.shared.roomInfoModel.roomId Url:streamUrl];
if (FUSSwiftLiveHelper.shared.roomInfoModel) {
[FUSSwiftLiveHelper.shared.roomInfoModel fus_setupWithModel:roomInfoModel];
} else {
FUSSwiftLiveHelper.shared.roomInfoModel = roomInfoModel;
}
[self.liveFunctionView fus_setupWithRoomInfoModel:roomInfoModel];
[FUSSocketMessageHelper fus_socketRoomConnectWithRoomId:roomInfoModel.roomId];
if ([roomInfoModel.livestate intValue] == 1) {
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_LIVE_STATE_CHANGE object:@"1"];
}
// 拉取在线用户列表
[FUSLiveHttpHelper fus_requestRoomOnlineUsersWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId count:@"0" success:^(NSArray *usersArr) {
[weakSelf.liveFunctionView fus_setupOnlineUsers:usersArr];
} failure:^(NSString *msg, int code) {
FUSLogError(@"拉取在线用户列表失败:%@",msg);
}];
} failure:^(NSDictionary *errorDict, NSString *msg, int code) {
[FUSDialogView fus_showDialog:msg];
}];
} failure:^(NSString *msg, int code) {
if (FUSConfig.sharedInstanced.liveConfigs.isAnchor) {
[FUSAlertView showAlertWithTitle:nil message:msg cancelButtonTitle:[NSString fus_localString:@"确定"] otherButtonTitles:nil clickBlock:^(NSInteger buttonIndex) {}];
}
}];
[weakSelf initLiveFunctionView];
}];
// 检查是否已经拥有麦克风/摄像头权限
if ([[FUSLiveHelper shareInstance] isAlreadyCheckAuths]) {
if ([FUSSwiftLiveHelper.shared isAlreadyCheckAuths]) {
// 有权限
[self initPushView];
[pushPrepareView initPushStartView];
......@@ -787,35 +883,12 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
//服务器启动推流
[FUSLiveHttpHelper fus_startPushStreamWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId] vdoid:[[[FUSLiveHelper shareInstance] streamModel] vdoid] livingWay:@"0" liveScope:[FUSLiveHelper shareInstance].roomScopeType success:^(NSDictionary *dict){
// [self initWaterMark];
[FUSLiveHelper shareInstance].roomInfoModel.channelId = [dict[@"channelId"] description];
[FUSLiveHelper shareInstance].roomInfoModel.stateSwitch = [FUSLiveRoomStateSwitchModel modelWithDictionary:dict[@"stateSwitch"]];
[FUSCacheDataShare shareStore].userBanScreenShot = [FUSLiveHelper shareInstance].roomInfoModel.stateSwitch.screenshotState;
if (FUSConfig.sharedInstanced.devConfigs.enableTestCode) {
[FUSDialogView fus_showDialog:[NSString stringWithFormat:@"测试:%@",[FUSLiveHelper shareInstance].roomInfoModel.channelId]];
}
// [[FUSLiveHelper shareInstance].currentFunctionView fus_refreshChatBtnWithPKState:[dict[@"isShowPk"] description]];
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_FUS_LIVE_ROOM_SHOW_PKBTN object:[dict[@"isShowPk"] description]];
[[FUSLiveHelper shareInstance].currentFunctionView fus_startRecordLiveTimeWithTime:[dict[@"livetime"] description]];
// 调用主播加入直播间
[weakSelf fus_enterRoom];
[FUSLiveHelper shareInstance].isStartedLive = YES;
// 更新直播状态
[FUSLiveHttpHelper fus_changeLiveStateWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId state:@"0" success:nil failure:nil];
[FUSLiveHelper shareInstance].roomInfoModel.channelId = [dict[@"channelId"] description];
if (FUSConfig.sharedInstanced.devConfigs.enableTestCode) {
[FUSDialogView fus_showDialog:[NSString stringWithFormat:@"测试:%@",[FUSLiveHelper shareInstance].roomInfoModel.channelId]];
if (!FUSBeautyHelper.shareInstance.faceBeautyOpened) {
FUSSocketMessageModel *model = [[FUSSocketMessageModel alloc] init];
model.extend1 = FUSSwiftLiveHelper.shared.roomInfoModel.roomId.intValue;
[[NSNotificationCenter defaultCenter] postNotificationName:STR(ROOM_CID_anchorDidCloseBeauty) object:model];
}
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveUDKeys.fus_IS_JOIN_ROOM_SUCCESS object:nil];
[weakSelf fus_startPushSucceedWithDict:dict];
} failure:^(NSString *msg, int code) {
if (FUSConfig.sharedInstanced.liveConfigs.isAnchor) {
......@@ -837,7 +910,84 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[self initLiveFunctionView];
}
- (void)fus_startPushSucceedWithDict:(NSDictionary *)dict {
[self.liveFunctionView fus_LivePushSuccess];
FUSSwiftLiveHelper.shared.roomInfoModel.channelId = [dict[@"channelId"] description];
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_FUS_LIVE_ROOM_SHOW_PKBTN object:[dict[@"isShowPk"] description]];
[self initPushStateView];
[FUSSwiftLiveHelper.shared.currentFunctionView fus_startRecordLiveTimeWithTime:[dict[@"livetime"] description]];
// 调用主播加入直播间
[self fus_enterRoom];
FUSSwiftLiveHelper.shared.isStartedLive = YES;
[FUSLiveHttpHelper fus_changeLiveStateWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId] state:@"0" success:^{
} failure:^(NSString *msg, int code) {
}];
FUSSwiftLiveHelper.shared.roomInfoModel.channelId = [dict[@"channelId"] description];
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveUDKeys.fus_IS_JOIN_ROOM_SUCCESS object:@(YES)];
__weak typeof(self) weakSelf = self;
self.streamView.pushView.captureHelper.completionHandler = ^(FUSStreamSessionState feedback) {
switch (feedback) {
case FUSStreamSessionStateStarted:
[NSObject cancelPreviousPerformRequestsWithTarget:weakSelf selector:@selector(fus_delayStartReconnectedLoading) object:nil];
[weakSelf fus_showLiveLoadingViewWithType:liveLoadingDismiss];
break;
case FUSStreamSessionStateStarting:
case FUSStreamSessionStateEnded:
case FUSStreamSessionStateNone:
break;
case FUSStreamSessionStateReconnecting:
case FUSStreamSessionStateError:
case FUSStreamSessionStateUrlerr:{
[NSObject cancelPreviousPerformRequestsWithTarget:weakSelf selector:@selector(fus_delayStartReconnectedLoading) object:nil];
[weakSelf performSelector:@selector(fus_delayStartReconnectedLoading) withObject:nil afterDelay:5];
break;
}
}
};
}
- (void)fus_delayStartReconnectedLoading {
[self fus_showLiveLoadingViewWithType:liveLoadingPushReconnecting];
}
/**
创建直播推流的速度
*/
- (void)initPushStateView
{
CGFloat bitrateImageWidth = 15.0;
if (!_bitrateImageView) {
_bitrateImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.pushView.width - 4 - bitrateImageWidth, HEAD_VIEW_HEIGHT - 50, bitrateImageWidth, bitrateImageWidth)];
_bitrateImageView.contentMode = UIViewContentModeScaleAspectFit;
_bitrateImageView.image = [FUSShowRoomCenterBunble imageNamed:@"live_push_bitrate_icon"];
_bitrateImageView.alpha = 0;
[self.pushView addSubview:_bitrateImageView];
}
if (!_bitrateLabel) {
_bitrateLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.pushView.width - _bitrateImageView.width - 10, 20)];
_bitrateLabel.textAlignment = NSTextAlignmentRight;
_bitrateLabel.font = [UIFont fus_themeFont:10];
_bitrateLabel.textColor = [UIColor colorWithWhite:1 alpha:0.5];
_bitrateLabel.centerY = _bitrateImageView.centerY;
_bitrateLabel.alpha = 0;
[self.pushView addSubview:_bitrateLabel];
}
}
/**
主播进入直播间
*/
......@@ -847,15 +997,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[FUSLiveHttpHelper fus_enterRoomGetPredataWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId success:^(NSDictionary *dataDict) {
NSArray *reminderKey = dataDict[@"reminderKey"];
NSDictionary *roomInfo = dataDict[@"roomInfo"];
if ([roomInfo[@"uid"] integerValue] != [FUSLiveHelper shareInstance].roomInfoModel.roomId.integerValue) {
FUSLogInfo(@"不是当前包房");
return ;
}
[FUSLiveHelper shareInstance].roomInfoModel.reminderKeys = reminderKey;
[self.liveFunctionView.chatTableView fus_addEnterRoomSystemTipMessage];
[weakSelf.liveFunctionView.chatTableView fus_addEnterRoomSystemTipMessage];
[weakSelf.liveFunctionView.pusherChatTableView fus_addEnterRoomSystemTipMessage];
[FUSLiveHttpHelper fus_enterRoomWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId vdoid:[FUSLiveHelper shareInstance].streamModel.vdoid behaviorSrc:@"" password:@"" success:^(FUSRoomInfoModel *roomInfoModel,BOOL micMode, NSString *streamUrl, NSString *pkInfo) {
......@@ -868,15 +1012,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
if (pkInfo.integerValue == 1) { //在pk中
// 审核下不显示PK
if(FUSConfig.sharedInstanced.devConfigs.appStatus) return;
// [FUSLiveHttpHelper fus_getRoomPKInfoWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId success:^(NSString *status, NSString *remainTime, NSString *winner, NSString *content,NSString *isLikePk,NSArray<FUSPKRoomPKInfoModel *> *userlistArray,NSString *matchId) {
// if (![roomInfoModel.roomId isEqualToString:[FUSLiveHelper shareInstance].roomInfoModel.roomId]) {
// FUSLogInfo(@"不是当前包房");
// return ;
// }
// [[FUSLiveHelper shareInstance].currentFunctionView fus_setupContentViewWithStatus:status remainTime:remainTime winner:winner content:content userlistArray:userlistArray isShowEntrance:YES];
// } failure:^(NSString *msg, int code) {
// FUSLogInfo(@"@%",msg);
// }];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[FUSSwiftLiveHelper.shared.pkHelper getRoomPKInfoWithRoomId:FUSSwiftLiveHelper.shared.roomInfoModel.roomId reconnect:1];
......@@ -909,7 +1044,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
} failure:^(NSDictionary *errorDict, NSString *msg, int code) {
[FUSDialogView fus_showDialog:msg];
}];
} failure:^(NSDictionary * _Nonnull errorDict, NSString * _Nonnull msg, int code) {
[FUSDialogView fus_showDialog:msg];
}];
// 拉取在线用户列表
[FUSLiveHttpHelper fus_requestRoomOnlineUsersWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId count:@"0" success:^(NSArray *usersArr) {
......@@ -918,10 +1055,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
} failure:^(NSString *msg, int code) {
FUSLogError(@"拉取在线用户列表失败:%@",msg);
}];
} failure:^(NSDictionary * _Nonnull errorDict, NSString * _Nonnull msg, int code) {
[FUSDialogView fus_showDialog:msg];
}];
}
/**
......@@ -932,6 +1065,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[self initLiveEndViewWithInfoDict:nil];
// 推流
[self.pushView.captureHelper fus_stopStreamPush];
// ludy: 这里加了一个停止采集的,对应之前经常准备开播页面关闭会崩溃的bug
[self.pushView.captureHelper fus_pauseAudioCapture];
if (self.pushView.streamType == FUSStreamTypeRTC) {
__weak typeof(self) weakSelf = self;
[self.pushView fus_stopRTCStreamingWithCompletion:^{
......@@ -941,7 +1077,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
self.pushView = nil;
}
// [self.playView fus_stopWithUID:[FUSLiveHelper shareInstance].roomInfoModel.roomId];
[self.playView fus_stopALLPlayer];
self.playView = nil;
[self.liveFunctionView fus_cleanFunctionView];
......@@ -966,6 +1101,8 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
/// @param left
- (void)fus_exitRoomLeftRoom:(BOOL)left completed:(void(^)(BOOL succeed))completed {
[FUSSwiftLiveHelper.shared.liveMinimizeView fus_destroy];
_isClickCloseBtn = YES;
[self.streamView fus_destroy];
......@@ -1118,8 +1255,10 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
_playView.mainUID = [FUSLiveHelper shareInstance].roomInfoModel.roomId;
[_playView fus_setVideoframeCallBackOpen:self.autoStartPictureInPicture forUid:self.playView.mainUID];
// self.hasEnterRoom = NO;
self.scrollEnableCount = 0;
if (self.autoStartPictureInPicture) {
[self setupPictureInPicture];
}
}
/**
......@@ -1192,121 +1331,21 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
}
}
#pragma mark - Lazy Load
- (UIView *)contentView
{
if (!_contentView) {
self.scrollView = [[FUSLiveScrollView alloc] initWithFrame:self.view.bounds];
_scrollView.contentSize = CGSizeMake(self.view.width, self.view.height * 3);
_scrollView.pagingEnabled = NO;
_scrollView.showsVerticalScrollIndicator = NO;
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.backgroundColor = [UIColor clearColor];
_scrollView.offsetY = UIView.fus_screenH;
_scrollView.delegate = self;
_scrollView.bounces = NO;
_scrollView.scrollsToTop = NO;
[self.view addSubview:_scrollView];
// 设置禁止滑动区域
self.scrollView.banScrollAreaRects = [self fus_baseBanScrollAreaRect];
// iOS 11 下调用新方法
if (@available(iOS 11.0, *)) {
_scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
if (_pushPrepareView) {
[self.view bringSubviewToFront:_pushPrepareView];
}
if (![FUSLiveHelper nextRoomInfoModel] &&
![FUSLiveHelper preRoomInfoModel]) {
#pragma mark - Method
/**
设置是否可以上下滑动切换包房
*/
- (void)setScrollEnableCount:(NSInteger)scrollEnableCount {
_scrollEnableCount = scrollEnableCount;
if (scrollEnableCount > 0) {
[self fus_setupScrollEnable:NO];
} else {
[self fus_setupScrollEnable:YES];
}
UIView *contentView = [[UIView alloc] initWithFrame:self.view.bounds];
contentView.y = UIView.fus_screenH;
contentView.backgroundColor = [UIColor clearColor];
[_scrollView addSubview:contentView];
self.contentView = contentView;
// 搭建背景 ImageView
_backgroundImageView = [[FUSBlurImageView alloc] initWithFrame:UIView.fus_screenFrame];
[_contentView addSubview:_backgroundImageView];
_backgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAudience || [FUSLiveHelper shareInstance].liveRoomType == FUSRoomTypeLinkMic) {
if ([NSString isNull:[[[FUSLiveHelper shareInstance] roomInfoModel] face]]) {
UIImage *bgImg = [[FUSShowRoomCenterBunble imageNamed:@"live_bg"] resizedImageToSize:CGSizeMake(500, 500)];
[_backgroundImageView fus_setImageWithImage:bgImg];
} else {
[_backgroundImageView fus_setWebImageWithSubURLString:[[[FUSLiveHelper shareInstance] roomInfoModel] face] placeholder:nil];
}
} else if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAnchor) {
}
// 搭建上下滑动主播背景图
if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAudience) {
// 搭建前一个主播背景图片
self.preBgImageView = [[FUSBlurImageView alloc] initWithFrame:CGRectMake(0, 0, UIView.fus_screenW, UIView.fus_screenH)];
_preBgImageView.userInteractionEnabled = YES;
[_scrollView addSubview:_preBgImageView];
// _preBgImageView.backgroundColor = [UIColor redColor];
_preBgImageView.contentMode = UIViewContentModeScaleAspectFill;
if ([NSString isNull:[[FUSLiveHelper preRoomInfoModel] face]]) {
UIImage *bgImg = [[FUSShowRoomCenterBunble imageNamed:@"live_bg"] resizedImageToSize:CGSizeMake(500, 500)];
[_preBgImageView fus_setImageWithImage:bgImg];
} else {
// 模糊
[_preBgImageView fus_setWebImageWithSubURLString:[[FUSLiveHelper preRoomInfoModel] face] placeholder:nil];
// 非模糊
// [[self preBgImageView] setWebImageWithSubURLString:[FUSLiveHelper preRoomInfoModel].face placeholder:nil completion:nil];
}
// 搭建下一个主播背景图片
self.nextBgImageView = [[FUSBlurImageView alloc] initWithFrame:CGRectMake(0, UIView.fus_screenH * 2, UIView.fus_screenW, UIView.fus_screenH)];
_nextBgImageView.userInteractionEnabled = YES;
[_scrollView addSubview:_nextBgImageView];
_nextBgImageView.contentMode = UIViewContentModeScaleAspectFill;
if ([NSString isNull:[[FUSLiveHelper nextRoomInfoModel] face]]) {
UIImage *bgImg = [[FUSShowRoomCenterBunble imageNamed:@"live_bg"] resizedImageToSize:CGSizeMake(500, 500)];
[_nextBgImageView fus_setImageWithImage:bgImg];
} else {
// 模糊
[_nextBgImageView fus_setWebImageWithSubURLString:[[FUSLiveHelper nextRoomInfoModel] face] placeholder:nil];
// 非模糊
// [[self nextBgImageView] setWebImageWithSubURLString:[FUSLiveHelper nextRoomInfoModel].face placeholder:nil completion:nil];
}
if (![FUSLiveHelper nextRoomInfoModel] &&
![FUSLiveHelper preRoomInfoModel]) {
[self fus_setupScrollEnable:NO];
}
}
}
return _contentView;
}
#pragma mark - Method
/**
设置是否可以上下滑动切换包房
*/
- (void)fus_setupScrollEnable:(BOOL)enable
{
// 数值相同,不修改
......@@ -1453,17 +1492,23 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
//WIFI
// 重连后发5555
NSString *liveType = @"0";
switch ([FUSSwiftLiveHelper.shared roomType]) {
case defaultRoom:
liveType = @"0";
break;
[FUSLiveHttpHelper fus_reconnectRoomWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId] livingType:liveType vdoid:[[[FUSLiveHelper shareInstance] streamModel] vdoid] success:^(FUSRoomInfoModel *roomInfoModel) {
[FUSSocketMessageHelper fus_socketRoomConnectWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId]];
} failure:^(NSString *msg, int code, NSDictionary *errorDict) {
case OBSRoom:
liveType = @"1";
break;
}];
default:
break;
}
[FUSSwiftLiveHelper.shared fus_requestReconnectRoomWithNeedResp:YES];
if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAudience) {
// [_playView fus_reloadPlayer];
[_playView fus_reloadPlayerWithUID:[FUSLiveHelper shareInstance].roomInfoModel.roomId];
} else if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAnchor) {
if ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAudience) {
[self.playView fus_reloadPlayerWithUID:FUSSwiftLiveHelper.shared.roomInfoModel.roomId];
} else if ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAnchor) {
}
......@@ -1529,6 +1574,22 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[FUSLiveHelper shareInstance].roomInfoModel.channelId = @"";
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_BaoFang_Did_End_Live_Notification object:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId]];
[self initLiveEndViewWithInfoDict:endViewDict];
if([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAudience){
[self initLiveEndViewWithInfoDict:endViewDict];
}
if ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAnchor) {
NSNumber *causeType = dict[@"causeType"];
NSString *causeString = dict[@"causeText"];
if (causeType.intValue == 0) {
[self initLiveEndViewWithInfoDict:dict];
}else{
[self initLiveEndViewWithInfoDict:nil];
[FUSDialogView fus_showDialog:causeString];
}
}
}
// 被踢出直播
......@@ -1546,12 +1607,20 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
NSString *liveType = @"0";
switch ([FUSSwiftLiveHelper.shared roomType]) {
case defaultRoom:
liveType = @"0";
break;
case OBSRoom:
liveType = @"1";
break;
default:
break;
}
[FUSSwiftLiveHelper.shared fus_requestReconnectRoomWithNeedResp:YES];
// [FUSLiveHttpHelper fus_exitRoomWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId] livingType:liveType vdoid:[[[FUSLiveHelper shareInstance] streamModel] vdoid] success:^(NSDictionary *dataDict) {
// [[FUSLiveHelper shareInstance].currentFunctionView.pkHelper fus_removeAllNotification];
// } failure:^(NSString *msg, int code, NSDictionary *errorDict) {
//
// }];
}
......@@ -1781,7 +1850,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
}
[FUSSwiftLiveHelper.shared fus_requestReconnectRoomWithNeedResp:YES];
if (FUSSwiftLiveHelper.shared.liveType == FUSLiveTypeAudience) {
if (FUSSwiftLiveHelper.shared.liveType == FUSLiveTypeAnchor) {
if ([FUSSwiftLiveHelper.shared roomType] == OBSRoom) {
return;
} else {
......@@ -1869,16 +1938,16 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
}
- (void)fus_liveFunctionView:(FUSLiveFunctionView *)functionView pkViewDidAddedWithInfoList:(NSArray<FUSPKRoomPKInfoModel *> *)pkInfoList {
// [self.pkHeaderView removeFromSuperview];
// CGRect frame = [self.playView fus_frameForUID:pkInfoList.firstObject.uid];
// frame.size.width = self.playView.width;
// self.pkHeaderView = [[FUSPKBottomUserHeaderView alloc] initWithFrame:frame userlistArray:pkInfoList];
// [self.playView.superview insertSubview:self.pkHeaderView belowSubview:self.playView];
[self.pkHeaderView removeFromSuperview];
CGRect frame = [self.playView fus_frameForUID:pkInfoList.firstObject.uid];
frame.size.width = self.playView.width;
self.pkHeaderView = [[FUSPKBottomUserHeaderView alloc] initWithFrame:frame userlistArray:pkInfoList];
[self.playView.superview insertSubview:self.pkHeaderView belowSubview:self.playView];
}
- (void)fus_liveFunctionViewPkViewDidRemoved:(FUSLiveFunctionView *)functionView {
// [self.pkHeaderView removeFromSuperview];
// self.pkHeaderView = nil;
[self.pkHeaderView removeFromSuperview];
self.pkHeaderView = nil;
}
/**
......@@ -2168,6 +2237,16 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[self.view addSubview:setThemeView];
}
-(void)fus_showQuickChatEditView{
[FUSLiveQuickChatSetAlertView fus_showOn:[[FUSLiveHelper shareInstance].currentFunctionView fus_viewWithLayer:FUSLiveFunctionLayerManualPopView] clickHandler:^{
}];
}
- (void)ffshowFollowSalutationView{
}
/**
弹出推流质量的View
*/
......@@ -2334,14 +2413,13 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
return self.playView;
}
//TODO: 索隆 - V57
// if ([self.preRoomPlayView.mainUID isEqual:mainUid]) {
// return self.preRoomPlayView;
// }
//
// if ([self.nextRoomPlayView.mainUID isEqual:mainUid]) {
// return self.nextRoomPlayView;
// }
if ([self.preRoomPlayView.mainUID isEqual:mainUid]) {
return self.preRoomPlayView;
}
if ([self.nextRoomPlayView.mainUID isEqual:mainUid]) {
return self.nextRoomPlayView;
}
return nil;
}
......@@ -2349,44 +2427,159 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
- (void)fus_showPasswordBlurView {
// self.passwordBlurView = [[UIVisualEffectView alloc] initWithFrame:self.view.bounds];
// self.passwordBlurView.effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
// self.passwordBlurView.alpha = 1;
// [self.view addSubview:self.passwordBlurView];
self.passwordBlurView = [[UIVisualEffectView alloc] initWithFrame:self.view.bounds];
self.passwordBlurView.effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
self.passwordBlurView.alpha = 1;
[self.view addSubview:self.passwordBlurView];
}
- (void)fus_updatePlayingView:(BOOL)showNextPlayer {
if (showNextPlayer == NO) {
[self.preRoomPlayView removeFromSuperview];
[self.streamView addSubview:self.preRoomPlayView];
self.preRoomPlayView.frame = self.streamView.bounds;
[self.streamView.playView removeFromSuperview];
id tempPlayView = self.streamView.playView;
self.streamView.playView = self.preRoomPlayView;
self.preRoomPlayView = tempPlayView;
[self.scrollView addSubview:self.preRoomPlayView];
self.preRoomPlayView.y = 0;
self.streamView.playView.hidden = NO;
[self.streamView.playView fus_openPlayerSound];
} else if (showNextPlayer == YES) {
[self.nextRoomPlayView removeFromSuperview];
[self.streamView addSubview:self.nextRoomPlayView];
self.nextRoomPlayView.frame = self.streamView.bounds;
[self.streamView.playView removeFromSuperview];
id tempPlayView = self.streamView.playView;
self.streamView.playView = self.nextRoomPlayView;
self.nextRoomPlayView = tempPlayView;
[self.scrollView addSubview:self.nextRoomPlayView];
self.nextRoomPlayView.y = (UIView.fus_screenH * 2);
self.streamView.playView.hidden = NO;
[self.streamView.playView fus_openPlayerSound];
}
__weak typeof(self) weakSelf = self;
//回调当前码率
[self.playView setPlayBitrateUpdateHandler:^(double bitrate) {
[weakSelf.liveFunctionView fus_updataBitrateWithRate:bitrate];
}];
if (self.pipController) {
self.pipController.contentView = self.playView;
}
[self fus_setupPreloadingPlayers];
}
- (void)fus_setupPreloadingPlayers {
FUSRoomInfoModel *premodel = [FUSSwiftLiveHelper preRoomInfoModel];
[self.preRoomPlayView fus_destroyAllPlayer];
self.preRoomPlayView.mainUID = premodel.roomId;
[self.preRoomPlayView fus_setupWithUID:premodel.roomId Url:premodel.publishUrl];
self.preRoomPlayView.isPreloadPlayer = YES;
self.preRoomPlayView.hidden = YES;
FUSRoomInfoModel *nextmodel = [FUSSwiftLiveHelper nextRoomInfoModel];
[self.nextRoomPlayView fus_destroyAllPlayer];
self.nextRoomPlayView.mainUID = nextmodel.roomId;
[self.nextRoomPlayView fus_setupWithUID:nextmodel.roomId Url:nextmodel.publishUrl];
self.nextRoomPlayView.isPreloadPlayer = YES;
self.nextRoomPlayView.hidden = YES;
self.preloadingPlayView = nil;
self.playView.isPreloadPlayer = YES;
}
- (void)fus_hidePasswordBlurView {
// [self.passwordBlurView removeFromSuperview];
// self.passwordBlurView = nil;
[self.passwordBlurView removeFromSuperview];
self.passwordBlurView = nil;
}
#pragma mark - ScrollView Delegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[self.view endEditing:YES];
CGFloat offsetY = self.scrollView.offsetY - self.beginY;
if (offsetY < 0) {
if (self.preloadingPlayView != self.preRoomPlayView) {
self.preloadingPlayView = self.preRoomPlayView;
self.preRoomPlayView.y = 0;
[self.nextRoomPlayView fus_pauseWithUID:[FUSSwiftLiveHelper nextRoomInfoModel].roomId];
[self.preRoomPlayView fus_playWithUID:[FUSSwiftLiveHelper preRoomInfoModel].roomId mutePlay:YES];
self.nextRoomPlayView.hidden = YES;
self.preRoomPlayView.hidden = NO;
}
} else if (offsetY > 0) {
if (self.preloadingPlayView != self.nextRoomPlayView) {
self.preloadingPlayView = self.nextRoomPlayView;
[self.preRoomPlayView fus_pauseWithUID:[FUSSwiftLiveHelper preRoomInfoModel].roomId];
[self.nextRoomPlayView fus_playWithUID:[FUSSwiftLiveHelper nextRoomInfoModel].roomId mutePlay:YES];
self.nextRoomPlayView.y = (UIView.fus_screenH * 2);
self.nextRoomPlayView.hidden = NO;
self.preRoomPlayView.hidden = YES;
}
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
if (_scrollView.offsetY == 0) {
_scrollView.offsetY = UIView.fus_screenH;
FUSRoomInfoModel *model = [FUSLiveHelper preRoomInfoModel];
[[FUSLiveHelper shareInstance] fus_switchRoomWithRoomInfoModel:model behaviorSrc:@"" success:nil failure:nil];
[self fus_setupScrollEnable:NO];
// 停止播放
[self fus_stopPlay];
FUSRoomInfoModel *model = [FUSSwiftLiveHelper preRoomInfoModel];
[FUSSwiftLiveHelper.shared switchRoomWithRoomInfoModel:model hasPreloadVideo:YES success:nil failure:nil];
[self fus_updatePlayingView:NO];
// 重置数据
[self fus_resetData];
self.scrollEnableCount += 1;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self fus_setupScrollEnable:YES];
self.scrollEnableCount -= 1;
[self fus_setupPreloadingPlayers];
});
// FUSRoomInfoModel *model = [FUSLiveHelper preRoomInfoModel];
// [[FUSLiveHelper shareInstance] fus_switchRoomWithRoomInfoModel:model behaviorSrc:@"" success:nil failure:nil];
// [self fus_setupScrollEnable:NO];
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// [self fus_setupScrollEnable:YES];
// });
}
if (_scrollView.offsetY == (UIView.fus_screenH * 2)) {
_scrollView.offsetY = UIView.fus_screenH;
FUSRoomInfoModel *model = [FUSLiveHelper nextRoomInfoModel];
[[FUSLiveHelper shareInstance] fus_switchRoomWithRoomInfoModel:model behaviorSrc:@"" success:nil failure:nil];
[self fus_setupScrollEnable:NO];
// 停止播放
[self fus_stopPlay];
FUSRoomInfoModel *model = [FUSSwiftLiveHelper nextRoomInfoModel];
[FUSSwiftLiveHelper.shared switchRoomWithRoomInfoModel:model hasPreloadVideo:YES success:nil failure:nil];
[self fus_updatePlayingView:YES];
// 重置数据
[self fus_resetData];
self.scrollEnableCount += 1;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self fus_setupScrollEnable:YES];
self.scrollEnableCount -= 1;
[self fus_setupPreloadingPlayers];
});
// FUSRoomInfoModel *model = [FUSLiveHelper nextRoomInfoModel];
// [[FUSLiveHelper shareInstance] fus_switchRoomWithRoomInfoModel:model behaviorSrc:@"" success:nil failure:nil];
// [self fus_setupScrollEnable:NO];
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// [self fus_setupScrollEnable:YES];
// });
}
self.scrollView.pagingEnabled = NO;
}
......@@ -2394,11 +2587,13 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
// pagingEnabled 如果設置了YES,那麼scrollView裡面內嵌的scrollView滾動會有問題,所以只有在當前scrollView滾動的時候才設置為yes
self.scrollView.pagingEnabled = YES;
self.beginY = scrollView.offsetY;
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (!decelerate) {
[self scrollViewDidEndDecelerating:scrollView];
self.scrollView.pagingEnabled = NO;
}
}
......@@ -2513,7 +2708,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
if (FUSLiveHelper.shareInstance.liveType != FUSLiveTypeAudience) {
return;
}
dispatch_async_on_main_queue(^{
[self destroyPlayPictureInPicture];
if (!self.pipController) {
......@@ -2521,7 +2716,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
self.pipController = [[VELPictureInPictureController alloc] initWithType:pipType
contentView:[self playView]];
self.pipController.videoGravity = AVLayerVideoGravityResizeAspectFill;
self.pipController.videoGravity = AVLayerVideoGravityResizeAspect;
self.pipController.delegate = self;
[self.pipController prepareWithCompletion:nil];
......@@ -2554,6 +2749,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
}
self.pipController.contentView = self.playView;
});
}
}
......@@ -2571,8 +2767,11 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
}
- (void)destroyPlayPictureInPicture {
dispatch_async_on_main_queue(^{
[self.pipController stopPictureInPicture];
[VELPictureInPictureController destroyPictureInPicture];
[self setPipController:nil];
});
}
+ (BOOL)isPictureInPictureStarted {
......
......@@ -350,6 +350,8 @@ typedef NS_ENUM(NSInteger, FUSFunctionMode) {
/// 清除所有半屏弹窗
-(void)fus_clearHalfWebView;
/// 通知functionview推流成功(也就是主播开播成功),用于引导,改变一些状态
- (void)fus_LivePushSuccess;
-(void)fus_reloadAllUserFromRequest;
......
......@@ -5286,7 +5286,11 @@ BDAlphaPlayerMetalViewDelegate
_enterRoomInterval += 1;
}
/// 通知functionview推流成功(也就是主播开播成功),用于引导,改变一些状态
- (void)fus_LivePushSuccess
{
}
/**
送礼提示展示逻辑
......
......@@ -13,6 +13,8 @@ typedef void(^PushSuccess)(void);
@interface FUSLivePushPrepareView : UIView
@property (nonatomic, copy) PushSuccess pushSuccessBlock;
// OBS 开播成功回调
@property (nonatomic, copy) PushSuccess obsPushSuccessHandler;
- (void)fus_checkDeviceAuths;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment