Commit 96e4a8c5 by ludi

Merge branch 'feature/v57版本pk迁移' of http://git.yabolive.net:88/pidan/FuSiLive…

Merge branch 'feature/v57版本pk迁移' of http://git.yabolive.net:88/pidan/FuSiLive into feature/v57版本pk迁移
parents 61c3ccd4 3c6c0868
...@@ -115,6 +115,10 @@ ...@@ -115,6 +115,10 @@
#define ROOM_CID_LIVE_ALERT 10090 // 接收到直播弹窗通知 #define ROOM_CID_LIVE_ALERT 10090 // 接收到直播弹窗通知
#define ROOM_CID_WEBVIEW_PUSH 10092 // 推送webview弹窗 #define ROOM_CID_WEBVIEW_PUSH 10092 // 推送webview弹窗
// 主播打开关闭麦克风socket
#define ROOM_CID_anchorDidCloseBeauty 20200
// 主播打开关闭麦克风socket
#define ROOM_CID_anchorDidCloseMic 20201
// 更新本场直播主题内容socket // 更新本场直播主题内容socket
#define ROOM_CID_LiveThemeDidChanged 20202 #define ROOM_CID_LiveThemeDidChanged 20202
...@@ -126,5 +130,3 @@ ...@@ -126,5 +130,3 @@
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
+ (CGFloat)fus_StatusBarHeight { + (CGFloat)fus_StatusBarHeight {
CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height; CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
return statusBarHeight < 20 ? 20 : statusBarHeight; return statusBarHeight < 20 ? (UIView.fus_SafeTop < 20 ? 20 : UIView.fus_SafeTop) : statusBarHeight;
} }
+ (CGFloat)fus_NavgationBarHeight { + (CGFloat)fus_NavgationBarHeight {
return 44; return 44;
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
/// pk试图的Y坐标 /// pk试图的Y坐标
+ (CGFloat)fus_pkViewYPosition { + (CGFloat)fus_pkViewYPosition {
return (UIView.fus_StatusBarHeight + 48); return (UIView.fus_StatusBarAndNavgationBarHeight + 48);
} }
/// pk主播试图高度 /// pk主播试图高度
......
...@@ -937,15 +937,18 @@ static NSString *const kBytePushSingleStreamToCDNKey = @"kBytePushSingleStreamTo ...@@ -937,15 +937,18 @@ static NSString *const kBytePushSingleStreamToCDNKey = @"kBytePushSingleStreamTo
- (void)startMixerPush { - (void)startMixerPush {
if (!self.rtcVideo || !self.mixConfig || !self.pushCDN) return; if (!self.rtcVideo || !self.mixConfig || !self.pushCDN) return;
// 新版核心 API:一键配置并启动合流转推(替代旧版 startPushMixedStreamToCDN) // 新版核心 API:一键配置并启动合流转推(替代旧版 startPushMixedStreamToCDN)
dispatch_async(dispatch_get_main_queue(), ^{
[self.rtcVideo updatePushMixedStreamToCDN:kBytePushMixedStreamToCDNKey mixedConfig:self.mixConfig]; [self.rtcVideo updatePushMixedStreamToCDN:kBytePushMixedStreamToCDNKey mixedConfig:self.mixConfig];
});
} }
// 开启合流转推(入房成功回调中调用,新版 API 简化为 configMixedStreamPush) // 开启合流转推(入房成功回调中调用,新版 API 简化为 configMixedStreamPush)
- (void)startMixerSinglePush { - (void)startMixerSinglePush {
if (!self.rtcVideo || !self.singleConfig || !self.pushCDN) return; if (!self.rtcVideo || !self.singleConfig || !self.pushCDN) return;
// 新版核心 API:一键配置并启动合流转推(替代旧版 startPushMixedStreamToCDN) // 新版核心 API:一键配置并启动合流转推(替代旧版 startPushMixedStreamToCDN)
dispatch_async(dispatch_get_main_queue(), ^{
[self.rtcVideo updatePushMixedStreamToCDN:kBytePushSingleStreamToCDNKey mixedConfig:self.singleConfig]; [self.rtcVideo updatePushMixedStreamToCDN:kBytePushSingleStreamToCDNKey mixedConfig:self.singleConfig];
});
} }
// 盘路推流单独推自己的流 // 盘路推流单独推自己的流
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#import "FUSLiveMainViewController.h" #import "FUSLiveMainViewController.h"
#import "FUSLiveManagerViewController.h" #import "FUSLiveManagerViewController.h"
#import "FUSLiveQuickChatSetAlertView.h"
#import "FUSLivePushPrepareView.h" #import "FUSLivePushPrepareView.h"
#import "FUSLiveHttpHelper.h" #import "FUSLiveHttpHelper.h"
#import "FUSSocketMessageDelegate.h" #import "FUSSocketMessageDelegate.h"
...@@ -62,6 +62,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -62,6 +62,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
@property (nonatomic, strong) UIButton *joinMicroBtn; @property (nonatomic, strong) UIButton *joinMicroBtn;
@property (nonatomic, strong) UIVisualEffectView *passwordBlurView;
/** /**
设置 Idle Time Disable 的Timer 设置 Idle Time Disable 的Timer
*/ */
...@@ -131,7 +132,12 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -131,7 +132,12 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
@property (nonatomic, assign) BOOL isClickCloseBtn; @property (nonatomic, assign) BOOL isClickCloseBtn;
// pk的时候,在画面下方显示的背景,防止画面还没显示出来一片黑的问题 // 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; @property (nonatomic, strong) VELPictureInPictureController *pipController;
/// pic in pic 启动成功回调 /// pic in pic 启动成功回调
...@@ -170,6 +176,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -170,6 +176,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[[FUSLiveGiftView shareGiftView] fus_cleanData]; [[FUSLiveGiftView shareGiftView] fus_cleanData];
[FUSSocketMessageCenter fus_setSocketHeartbeatInterval:10000];
// 载入首充数据 // 载入首充数据
[[FUSLiveGiftView shareGiftView] fus_reloadFirstCharge]; [[FUSLiveGiftView shareGiftView] fus_reloadFirstCharge];
} }
...@@ -201,7 +208,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -201,7 +208,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
self.autoStartPictureInPicture = FUSSwiftLiveHelper.shared.autoStartPictureInPicture; self.autoStartPictureInPicture = FUSSwiftLiveHelper.shared.autoStartPictureInPicture;
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_liveRoomViewDidAppear object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_liveRoomViewDidAppear object:nil];
// [self fus_setupPreloadingPlayers]; [self fus_setupPreloadingPlayers];
FUSSwiftLiveHelper.shared.oc_liveRoomLifeCycle = FUSLiveRoomVCLifeCycleAppear; FUSSwiftLiveHelper.shared.oc_liveRoomLifeCycle = FUSLiveRoomVCLifeCycleAppear;
} }
...@@ -581,10 +588,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -581,10 +588,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
- (void)initLiveFunctionView { - (void)initLiveFunctionView {
_isClickCloseBtn = NO; _isClickCloseBtn = NO;
[self fus_initContentView];
// 防止多次创建 LiveFunctionView // 防止多次创建 LiveFunctionView
if (_liveFunctionView) { if (_liveFunctionView) {
// [_liveFunctionView removeFromSuperview];
[self.contentView addSubview:_liveFunctionView]; [self.contentView addSubview:_liveFunctionView];
return; return;
} }
...@@ -599,9 +605,14 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -599,9 +605,14 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
*/ */
- (void)initStreamView - (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; return;
} }
}
switch (FUSLiveHelper.shareInstance.liveType) { switch (FUSLiveHelper.shareInstance.liveType) {
case FUSLiveTypeAnchor: case FUSLiveTypeAnchor:
...@@ -643,14 +654,14 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -643,14 +654,14 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
case FUSLiveTypeAudience: case FUSLiveTypeAudience:
{ {
// self.preRoomPlayView = [[YAStreamPlayView alloc] initWithFrame:self.scrollView.bounds]; self.preRoomPlayView = [[FUSStreamPlayView alloc] initWithFrame:self.scrollView.bounds];
// self.preRoomPlayView.hidden = YES; self.preRoomPlayView.hidden = YES;
// [self.scrollView addSubview:self.preRoomPlayView]; [self.scrollView addSubview:self.preRoomPlayView];
//
// self.nextRoomPlayView = [[YAStreamPlayView alloc] initWithFrame:self.scrollView.bounds]; self.nextRoomPlayView = [[FUSStreamPlayView alloc] initWithFrame:self.scrollView.bounds];
// self.nextRoomPlayView.hidden = YES; self.nextRoomPlayView.hidden = YES;
// self.nextRoomPlayView.y = self.scrollView.height * 2; self.nextRoomPlayView.y = self.scrollView.height * 2;
// [self.scrollView addSubview:self.nextRoomPlayView]; [self.scrollView addSubview:self.nextRoomPlayView];
// 搭建观众端拉流 View // 搭建观众端拉流 View
_streamView = [[FUSLiveStreamView alloc] initPlayViewWithFrame:self.contentView.bounds]; _streamView = [[FUSLiveStreamView alloc] initPlayViewWithFrame:self.contentView.bounds];
...@@ -658,10 +669,10 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -658,10 +669,10 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[_streamView.playView fus_setVideoframeCallBackOpen:self.autoStartPictureInPicture forUid:self.streamView.playView.mainUID]; [_streamView.playView fus_setVideoframeCallBackOpen:self.autoStartPictureInPicture forUid:self.streamView.playView.mainUID];
[_contentView addSubview:_streamView]; [_contentView addSubview:_streamView];
[FUSLiveHelper shareInstance].streamView = _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通知 // 进入包房成功提示送礼view通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recieveJoinRoomSuccessNotification) name:FUSLiveUDKeys.fus_IS_JOIN_ROOM_SUCCESS object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recieveJoinRoomSuccessNotification) name:FUSLiveUDKeys.fus_IS_JOIN_ROOM_SUCCESS object:nil];
...@@ -699,8 +710,94 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -699,8 +710,94 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[weakSelf fus_startPush]; [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]; [self initPushView];
[pushPrepareView initPushStartView]; [pushPrepareView initPushStartView];
...@@ -787,35 +884,12 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -787,35 +884,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){ [FUSLiveHttpHelper fus_startPushStreamWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId] vdoid:[[[FUSLiveHelper shareInstance] streamModel] vdoid] livingWay:@"0" liveScope:[FUSLiveHelper shareInstance].roomScopeType success:^(NSDictionary *dict){
// [self initWaterMark]; if (!FUSBeautyHelper.shareInstance.faceBeautyOpened) {
[FUSLiveHelper shareInstance].roomInfoModel.channelId = [dict[@"channelId"] description]; FUSSocketMessageModel *model = [[FUSSocketMessageModel alloc] init];
model.extend1 = FUSSwiftLiveHelper.shared.roomInfoModel.roomId.intValue;
[FUSLiveHelper shareInstance].roomInfoModel.stateSwitch = [FUSLiveRoomStateSwitchModel modelWithDictionary:dict[@"stateSwitch"]]; [[NSNotificationCenter defaultCenter] postNotificationName:STR(ROOM_CID_anchorDidCloseBeauty) object:model];
[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]];
} }
[weakSelf fus_startPushSucceedWithDict:dict];
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveUDKeys.fus_IS_JOIN_ROOM_SUCCESS object:nil];
} failure:^(NSString *msg, int code) { } failure:^(NSString *msg, int code) {
if (FUSConfig.sharedInstanced.liveConfigs.isAnchor) { if (FUSConfig.sharedInstanced.liveConfigs.isAnchor) {
...@@ -837,7 +911,84 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -837,7 +911,84 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[self initLiveFunctionView]; [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 +998,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -847,15 +998,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[FUSLiveHttpHelper fus_enterRoomGetPredataWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId success:^(NSDictionary *dataDict) { [FUSLiveHttpHelper fus_enterRoomGetPredataWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId success:^(NSDictionary *dataDict) {
NSArray *reminderKey = dataDict[@"reminderKey"]; NSArray *reminderKey = dataDict[@"reminderKey"];
NSDictionary *roomInfo = dataDict[@"roomInfo"];
if ([roomInfo[@"uid"] integerValue] != [FUSLiveHelper shareInstance].roomInfoModel.roomId.integerValue) {
FUSLogInfo(@"不是当前包房");
return ;
}
[FUSLiveHelper shareInstance].roomInfoModel.reminderKeys = reminderKey; [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) { [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 +1013,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -868,15 +1013,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
if (pkInfo.integerValue == 1) { //在pk中 if (pkInfo.integerValue == 1) { //在pk中
// 审核下不显示PK // 审核下不显示PK
if(FUSConfig.sharedInstanced.devConfigs.appStatus) return; 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(), ^{ 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]; [FUSSwiftLiveHelper.shared.pkHelper getRoomPKInfoWithRoomId:FUSSwiftLiveHelper.shared.roomInfoModel.roomId reconnect:1];
...@@ -909,7 +1045,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -909,7 +1045,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
} failure:^(NSDictionary *errorDict, NSString *msg, int code) { } failure:^(NSDictionary *errorDict, NSString *msg, int code) {
[FUSDialogView fus_showDialog:msg]; [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) { [FUSLiveHttpHelper fus_requestRoomOnlineUsersWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId count:@"0" success:^(NSArray *usersArr) {
...@@ -918,10 +1056,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -918,10 +1056,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
} failure:^(NSString *msg, int code) { } failure:^(NSString *msg, int code) {
FUSLogError(@"拉取在线用户列表失败:%@",msg); FUSLogError(@"拉取在线用户列表失败:%@",msg);
}]; }];
} failure:^(NSDictionary * _Nonnull errorDict, NSString * _Nonnull msg, int code) {
[FUSDialogView fus_showDialog:msg];
}];
} }
/** /**
...@@ -932,6 +1066,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -932,6 +1066,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[self initLiveEndViewWithInfoDict:nil]; [self initLiveEndViewWithInfoDict:nil];
// 推流 // 推流
[self.pushView.captureHelper fus_stopStreamPush]; [self.pushView.captureHelper fus_stopStreamPush];
// ludy: 这里加了一个停止采集的,对应之前经常准备开播页面关闭会崩溃的bug
[self.pushView.captureHelper fus_pauseAudioCapture];
if (self.pushView.streamType == FUSStreamTypeRTC) { if (self.pushView.streamType == FUSStreamTypeRTC) {
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
[self.pushView fus_stopRTCStreamingWithCompletion:^{ [self.pushView fus_stopRTCStreamingWithCompletion:^{
...@@ -941,7 +1078,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -941,7 +1078,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
self.pushView = nil; self.pushView = nil;
} }
// [self.playView fus_stopWithUID:[FUSLiveHelper shareInstance].roomInfoModel.roomId];
[self.playView fus_stopALLPlayer]; [self.playView fus_stopALLPlayer];
self.playView = nil; self.playView = nil;
[self.liveFunctionView fus_cleanFunctionView]; [self.liveFunctionView fus_cleanFunctionView];
...@@ -966,6 +1102,8 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -966,6 +1102,8 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
/// @param left /// @param left
- (void)fus_exitRoomLeftRoom:(BOOL)left completed:(void(^)(BOOL succeed))completed { - (void)fus_exitRoomLeftRoom:(BOOL)left completed:(void(^)(BOOL succeed))completed {
[FUSSwiftLiveHelper.shared.liveMinimizeView fus_destroy];
_isClickCloseBtn = YES; _isClickCloseBtn = YES;
[self.streamView fus_destroy]; [self.streamView fus_destroy];
...@@ -1118,8 +1256,10 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -1118,8 +1256,10 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
_playView.mainUID = [FUSLiveHelper shareInstance].roomInfoModel.roomId; _playView.mainUID = [FUSLiveHelper shareInstance].roomInfoModel.roomId;
[_playView fus_setVideoframeCallBackOpen:self.autoStartPictureInPicture forUid:self.playView.mainUID]; [_playView fus_setVideoframeCallBackOpen:self.autoStartPictureInPicture forUid:self.playView.mainUID];
self.scrollEnableCount = 0;
// self.hasEnterRoom = NO; if (self.autoStartPictureInPicture) {
[self setupPictureInPicture];
}
} }
/** /**
...@@ -1192,121 +1332,21 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -1192,121 +1332,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) { #pragma mark - Method
[self.view bringSubviewToFront:_pushPrepareView]; /**
} 设置是否可以上下滑动切换包房
*/
if (![FUSLiveHelper nextRoomInfoModel] && - (void)setScrollEnableCount:(NSInteger)scrollEnableCount {
![FUSLiveHelper preRoomInfoModel]) { _scrollEnableCount = scrollEnableCount;
if (scrollEnableCount > 0) {
[self fus_setupScrollEnable:NO]; [self fus_setupScrollEnable:NO];
} else { } else {
[self fus_setupScrollEnable:YES]; [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 - (void)fus_setupScrollEnable:(BOOL)enable
{ {
// 数值相同,不修改 // 数值相同,不修改
...@@ -1453,17 +1493,23 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -1453,17 +1493,23 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
//WIFI //WIFI
// 重连后发5555 // 重连后发5555
NSString *liveType = @"0"; 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) { case OBSRoom:
[FUSSocketMessageHelper fus_socketRoomConnectWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId]]; liveType = @"1";
} failure:^(NSString *msg, int code, NSDictionary *errorDict) { break;
}]; default:
break;
}
[FUSSwiftLiveHelper.shared fus_requestReconnectRoomWithNeedResp:YES];
if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAudience) { if ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAudience) {
// [_playView fus_reloadPlayer]; [self.playView fus_reloadPlayerWithUID:FUSSwiftLiveHelper.shared.roomInfoModel.roomId];
[_playView fus_reloadPlayerWithUID:[FUSLiveHelper shareInstance].roomInfoModel.roomId]; } else if ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAnchor) {
} else if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAnchor) {
} }
...@@ -1529,6 +1575,22 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -1529,6 +1575,22 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[FUSLiveHelper shareInstance].roomInfoModel.channelId = @""; [FUSLiveHelper shareInstance].roomInfoModel.channelId = @"";
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_BaoFang_Did_End_Live_Notification object:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId]]; [[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_BaoFang_Did_End_Live_Notification object:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId]];
[self initLiveEndViewWithInfoDict:endViewDict]; [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 +1608,20 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -1546,12 +1608,20 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
NSString *liveType = @"0"; NSString *liveType = @"0";
switch ([FUSSwiftLiveHelper.shared roomType]) {
case defaultRoom:
liveType = @"0";
break;
case OBSRoom:
liveType = @"1";
break;
default:
break;
}
[FUSSwiftLiveHelper.shared fus_requestReconnectRoomWithNeedResp:YES]; [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 +1851,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -1781,7 +1851,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
} }
[FUSSwiftLiveHelper.shared fus_requestReconnectRoomWithNeedResp:YES]; [FUSSwiftLiveHelper.shared fus_requestReconnectRoomWithNeedResp:YES];
if (FUSSwiftLiveHelper.shared.liveType == FUSLiveTypeAudience) { if (FUSSwiftLiveHelper.shared.liveType == FUSLiveTypeAnchor) {
if ([FUSSwiftLiveHelper.shared roomType] == OBSRoom) { if ([FUSSwiftLiveHelper.shared roomType] == OBSRoom) {
return; return;
} else { } else {
...@@ -1869,16 +1939,16 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -1869,16 +1939,16 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
} }
- (void)fus_liveFunctionView:(FUSLiveFunctionView *)functionView pkViewDidAddedWithInfoList:(NSArray<FUSPKRoomPKInfoModel *> *)pkInfoList { - (void)fus_liveFunctionView:(FUSLiveFunctionView *)functionView pkViewDidAddedWithInfoList:(NSArray<FUSPKRoomPKInfoModel *> *)pkInfoList {
// [self.pkHeaderView removeFromSuperview]; [self.pkHeaderView removeFromSuperview];
// CGRect frame = [self.playView fus_frameForUID:pkInfoList.firstObject.uid]; CGRect frame = [self.playView fus_frameForUID:pkInfoList.firstObject.uid];
// frame.size.width = self.playView.width; frame.size.width = self.playView.width;
// self.pkHeaderView = [[FUSPKBottomUserHeaderView alloc] initWithFrame:frame userlistArray:pkInfoList]; self.pkHeaderView = [[FUSPKBottomUserHeaderView alloc] initWithFrame:frame userlistArray:pkInfoList];
// [self.playView.superview insertSubview:self.pkHeaderView belowSubview:self.playView]; [self.playView.superview insertSubview:self.pkHeaderView belowSubview:self.playView];
} }
- (void)fus_liveFunctionViewPkViewDidRemoved:(FUSLiveFunctionView *)functionView { - (void)fus_liveFunctionViewPkViewDidRemoved:(FUSLiveFunctionView *)functionView {
// [self.pkHeaderView removeFromSuperview]; [self.pkHeaderView removeFromSuperview];
// self.pkHeaderView = nil; self.pkHeaderView = nil;
} }
/** /**
...@@ -2168,6 +2238,16 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -2168,6 +2238,16 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[self.view addSubview:setThemeView]; [self.view addSubview:setThemeView];
} }
-(void)fus_showQuickChatEditView{
[FUSLiveQuickChatSetAlertView fus_showOn:[[FUSLiveHelper shareInstance].currentFunctionView fus_viewWithLayer:FUSLiveFunctionLayerManualPopView] clickHandler:^{
}];
}
- (void)ffshowFollowSalutationView{
}
/** /**
弹出推流质量的View 弹出推流质量的View
*/ */
...@@ -2334,14 +2414,13 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -2334,14 +2414,13 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
return self.playView; return self.playView;
} }
//TODO: 索隆 - V57 if ([self.preRoomPlayView.mainUID isEqual:mainUid]) {
// if ([self.preRoomPlayView.mainUID isEqual:mainUid]) { return self.preRoomPlayView;
// return self.preRoomPlayView; }
// }
// if ([self.nextRoomPlayView.mainUID isEqual:mainUid]) {
// if ([self.nextRoomPlayView.mainUID isEqual:mainUid]) { return self.nextRoomPlayView;
// return self.nextRoomPlayView; }
// }
return nil; return nil;
} }
...@@ -2349,44 +2428,159 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -2349,44 +2428,159 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
- (void)fus_showPasswordBlurView { - (void)fus_showPasswordBlurView {
// self.passwordBlurView = [[UIVisualEffectView alloc] initWithFrame:self.view.bounds]; self.passwordBlurView = [[UIVisualEffectView alloc] initWithFrame:self.view.bounds];
// self.passwordBlurView.effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; self.passwordBlurView.effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
// self.passwordBlurView.alpha = 1; self.passwordBlurView.alpha = 1;
// [self.view addSubview:self.passwordBlurView]; [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 { - (void)fus_hidePasswordBlurView {
// [self.passwordBlurView removeFromSuperview]; [self.passwordBlurView removeFromSuperview];
// self.passwordBlurView = nil; self.passwordBlurView = nil;
} }
#pragma mark - ScrollView Delegate #pragma mark - ScrollView Delegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView - (void)scrollViewDidScroll:(UIScrollView *)scrollView
{ {
[self.view endEditing:YES]; [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 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{ {
if (_scrollView.offsetY == 0) { if (_scrollView.offsetY == 0) {
_scrollView.offsetY = UIView.fus_screenH; _scrollView.offsetY = UIView.fus_screenH;
FUSRoomInfoModel *model = [FUSLiveHelper preRoomInfoModel]; // 停止播放
[[FUSLiveHelper shareInstance] fus_switchRoomWithRoomInfoModel:model behaviorSrc:@"" success:nil failure:nil]; [self fus_stopPlay];
[self fus_setupScrollEnable:NO]; 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(), ^{ 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)) { if (_scrollView.offsetY == (UIView.fus_screenH * 2)) {
_scrollView.offsetY = UIView.fus_screenH; _scrollView.offsetY = UIView.fus_screenH;
FUSRoomInfoModel *model = [FUSLiveHelper nextRoomInfoModel]; // 停止播放
[[FUSLiveHelper shareInstance] fus_switchRoomWithRoomInfoModel:model behaviorSrc:@"" success:nil failure:nil]; [self fus_stopPlay];
[self fus_setupScrollEnable:NO]; 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(), ^{ 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; self.scrollView.pagingEnabled = NO;
} }
...@@ -2394,11 +2588,13 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -2394,11 +2588,13 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
// pagingEnabled 如果設置了YES,那麼scrollView裡面內嵌的scrollView滾動會有問題,所以只有在當前scrollView滾動的時候才設置為yes // pagingEnabled 如果設置了YES,那麼scrollView裡面內嵌的scrollView滾動會有問題,所以只有在當前scrollView滾動的時候才設置為yes
self.scrollView.pagingEnabled = YES; self.scrollView.pagingEnabled = YES;
self.beginY = scrollView.offsetY;
} }
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (!decelerate) { if (!decelerate) {
[self scrollViewDidEndDecelerating:scrollView];
self.scrollView.pagingEnabled = NO; self.scrollView.pagingEnabled = NO;
} }
} }
...@@ -2513,7 +2709,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -2513,7 +2709,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
if (FUSLiveHelper.shareInstance.liveType != FUSLiveTypeAudience) { if (FUSLiveHelper.shareInstance.liveType != FUSLiveTypeAudience) {
return; return;
} }
dispatch_async_on_main_queue(^{
[self destroyPlayPictureInPicture]; [self destroyPlayPictureInPicture];
if (!self.pipController) { if (!self.pipController) {
...@@ -2521,7 +2717,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -2521,7 +2717,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
self.pipController = [[VELPictureInPictureController alloc] initWithType:pipType self.pipController = [[VELPictureInPictureController alloc] initWithType:pipType
contentView:[self playView]]; contentView:[self playView]];
self.pipController.videoGravity = AVLayerVideoGravityResizeAspectFill; self.pipController.videoGravity = AVLayerVideoGravityResizeAspect;
self.pipController.delegate = self; self.pipController.delegate = self;
[self.pipController prepareWithCompletion:nil]; [self.pipController prepareWithCompletion:nil];
...@@ -2554,6 +2750,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -2554,6 +2750,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
} }
self.pipController.contentView = self.playView; self.pipController.contentView = self.playView;
});
} }
} }
...@@ -2571,8 +2768,11 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -2571,8 +2768,11 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
} }
- (void)destroyPlayPictureInPicture { - (void)destroyPlayPictureInPicture {
dispatch_async_on_main_queue(^{
[self.pipController stopPictureInPicture];
[VELPictureInPictureController destroyPictureInPicture]; [VELPictureInPictureController destroyPictureInPicture];
[self setPipController:nil]; [self setPipController:nil];
});
} }
+ (BOOL)isPictureInPictureStarted { + (BOOL)isPictureInPictureStarted {
......
...@@ -1035,6 +1035,7 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor ...@@ -1035,6 +1035,7 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor
} else { } else {
FUSResourceDownloader.shareInstance.bitrateLimit = FUSResourceDownloaderBitrateLimitedNoLimit; FUSResourceDownloader.shareInstance.bitrateLimit = FUSResourceDownloaderBitrateLimitedNoLimit;
} }
[FUSSocketMessageCenter fus_setSocketHeartbeatInterval:30000];
} }
/** /**
......
...@@ -353,6 +353,8 @@ typedef NS_ENUM(NSInteger, FUSFunctionMode) { ...@@ -353,6 +353,8 @@ typedef NS_ENUM(NSInteger, FUSFunctionMode) {
/// 清除所有半屏弹窗 /// 清除所有半屏弹窗
-(void)fus_clearHalfWebView; -(void)fus_clearHalfWebView;
/// 通知functionview推流成功(也就是主播开播成功),用于引导,改变一些状态
- (void)fus_LivePushSuccess;
-(void)fus_reloadAllUserFromRequest; -(void)fus_reloadAllUserFromRequest;
......
...@@ -1620,6 +1620,8 @@ BDAlphaPlayerMetalViewDelegate ...@@ -1620,6 +1620,8 @@ BDAlphaPlayerMetalViewDelegate
*/ */
- (void)fus_initVolumnView - (void)fus_initVolumnView
{ {
// 移除自定义音量条和系统音量提示隐藏逻辑,恢复系统默认音量提示
/*
_volumnBGView = [[UIView alloc] initWithFrame:CGRectMake(0, UIView.fus_screenH - UIView.fus_SafeBottom - 1.5, UIView.fus_screenW, 1.5)]; _volumnBGView = [[UIView alloc] initWithFrame:CGRectMake(0, UIView.fus_screenH - UIView.fus_SafeBottom - 1.5, UIView.fus_screenW, 1.5)];
_volumnBGView.backgroundColor = [UIColor colorWithHex:@"C7C7CC" alpha:0.8]; _volumnBGView.backgroundColor = [UIColor colorWithHex:@"C7C7CC" alpha:0.8];
[self addSubview:_volumnBGView]; [self addSubview:_volumnBGView];
...@@ -1632,7 +1634,7 @@ BDAlphaPlayerMetalViewDelegate ...@@ -1632,7 +1634,7 @@ BDAlphaPlayerMetalViewDelegate
_volumnBGView.alpha = 0; _volumnBGView.alpha = 0;
MPVolumeView *systemVolumnView = [[MPVolumeView alloc] initWithFrame:CGRectMake(0, -2000, 0, 0)]; MPVolumeView *systemVolumnView = [[MPVolumeView alloc] initWithFrame:CGRectMake(0, -2000, 0, 0)];
[self addSubview:systemVolumnView]; [self addSubview:systemVolumnView];
*/
} }
-(void)fus_reloadRealtimeActivityWebView{ -(void)fus_reloadRealtimeActivityWebView{
...@@ -5448,7 +5450,11 @@ BDAlphaPlayerMetalViewDelegate ...@@ -5448,7 +5450,11 @@ BDAlphaPlayerMetalViewDelegate
_enterRoomInterval += 1; _enterRoomInterval += 1;
} }
/// 通知functionview推流成功(也就是主播开播成功),用于引导,改变一些状态
- (void)fus_LivePushSuccess
{
}
/** /**
送礼提示展示逻辑 送礼提示展示逻辑
......
...@@ -104,10 +104,12 @@ ...@@ -104,10 +104,12 @@
[self addSubview:_itemCollectionView]; [self addSubview:_itemCollectionView];
_normalImageDict = @{[NSString stringWithFormat:@"%ld",FUSItemViewOpenMic]:@"live_link_mic_voice_close", _normalImageDict = @{[NSString stringWithFormat:@"%ld",FUSItemViewCloseMic]:@"live_link_mic_voice_close",
[NSString stringWithFormat:@"%ld",FUSItemViewHomeMic]:@"live_link_mic_voice_home", [NSString stringWithFormat:@"%ld",FUSItemViewHomeMic]:@"live_link_mic_voice_home",
[NSString stringWithFormat:@"%ld",FUSItemViewDeleteMic]:@"live_link_mic_voice_delete", [NSString stringWithFormat:@"%ld",FUSItemViewDeleteMic]:@"live_link_mic_voice_delete",
[NSString stringWithFormat:@"%ld",FUSItemViewSendGift]:@"live_gift_view_icon_hl"}; [NSString stringWithFormat:@"%ld",FUSItemViewSendGift]:@"live_gift_view_icon_hl",
[NSString stringWithFormat:@"%ld",FUSItemViewOpenMic]:@"live_link_mic_voice_open",
};
// _hightlightedImageDict = @{[NSString stringWithFormat:@"%ld",FUSItemViewOpenMic]:@"live_link_mic_voice_close", // _hightlightedImageDict = @{[NSString stringWithFormat:@"%ld",FUSItemViewOpenMic]:@"live_link_mic_voice_close",
// [NSString stringWithFormat:@"%ld",FUSItemViewHomeMic]:@"live_link_mic_voice_home", // [NSString stringWithFormat:@"%ld",FUSItemViewHomeMic]:@"live_link_mic_voice_home",
......
...@@ -13,6 +13,8 @@ typedef void(^PushSuccess)(void); ...@@ -13,6 +13,8 @@ typedef void(^PushSuccess)(void);
@interface FUSLivePushPrepareView : UIView @interface FUSLivePushPrepareView : UIView
@property (nonatomic, copy) PushSuccess pushSuccessBlock; @property (nonatomic, copy) PushSuccess pushSuccessBlock;
// OBS 开播成功回调
@property (nonatomic, copy) PushSuccess obsPushSuccessHandler;
- (void)fus_checkDeviceAuths; - (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