Commit 3a7cd110 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 11326143 187f7b27
...@@ -260,6 +260,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -260,6 +260,9 @@ NS_ASSUME_NONNULL_BEGIN
/// liveroom将要显示,用来通知一些地方需要刷新 /// liveroom将要显示,用来通知一些地方需要刷新
+ (NSString *)fus_liveRoomViewWillAppear; + (NSString *)fus_liveRoomViewWillAppear;
/// liveroom已经显示,用来通知一些地方需要刷新
+ (NSString *)fus_liveRoomViewDidAppear;
@end @end
......
...@@ -425,6 +425,12 @@ ...@@ -425,6 +425,12 @@
return @"fus_liveRoomViewWillAppear"; return @"fus_liveRoomViewWillAppear";
} }
/// liveroom已经显示,用来通知一些地方需要刷新
+ (NSString *)fus_liveRoomViewDidAppear
{
return @"fus_liveRoomViewDidAppear";
}
@end @end
@implementation FUSLiveEventTrackParams @implementation FUSLiveEventTrackParams
......
...@@ -50,18 +50,14 @@ typedef enum : NSUInteger { ...@@ -50,18 +50,14 @@ typedef enum : NSUInteger {
当前主播背景图片 ImageView 当前主播背景图片 ImageView
*/ */
@property (nonatomic, strong) FUSBlurImageView *backgroundImageView; @property (nonatomic, strong) FUSBlurImageView *backgroundImageView;
// 切换直播间滚动计数,如果 = 0。则可滚动,> 0则不可滚动
@property (nonatomic, assign) NSInteger scrollEnableCount;
/** /**
初始化推流 初始化推流
*/ */
- (void)initPushPrepareView; - (void)initPushPrepareView;
/** /**
初始化视讯推流
*/
//- (void)initPrivatePushPrepareView;
/**
设置是否可以上下滑动切换包房 设置是否可以上下滑动切换包房
*/ */
- (void)fus_setupScrollEnable:(BOOL)enable; - (void)fus_setupScrollEnable:(BOOL)enable;
...@@ -130,6 +126,11 @@ typedef enum : NSUInteger { ...@@ -130,6 +126,11 @@ typedef enum : NSUInteger {
*/ */
- (void)fus_showLiveThemeView; - (void)fus_showLiveThemeView;
/// 显示快捷发言的view
- (void)fus_showQuickChatEditView;
/// 显示关注问候view
-(void)fus_showFollowSalutationView;
/** /**
弹出推流质量的View 弹出推流质量的View
*/ */
...@@ -178,7 +179,7 @@ typedef enum : NSUInteger { ...@@ -178,7 +179,7 @@ typedef enum : NSUInteger {
- (NSString *)fus_getLiveBitrate; - (NSString *)fus_getLiveBitrate;
- (void)fus_showPasswordBlurView; - (void)fus_showPasswordBlurView;
//
- (void)fus_hidePasswordBlurView; - (void)fus_hidePasswordBlurView;
@end @end
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
// test // test
#import "FUSLiveHeadView.h" #import "FUSLiveHeadView.h"
#import "FUSAgoraHelper.h"
#import "VELPictureInPictureController.h" #import "VELPictureInPictureController.h"
#import <FUSFoundation/FUSFoundation-Swift.h> #import <FUSFoundation/FUSFoundation-Swift.h>
...@@ -61,7 +60,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -61,7 +60,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
@property (nonatomic, strong) CTCallCenter *callCenter; @property (nonatomic, strong) CTCallCenter *callCenter;
@property (nonatomic, strong) FUSAgoraHelper *agoraHelper;
@property (nonatomic, strong) UIButton *joinMicroBtn; @property (nonatomic, strong) UIButton *joinMicroBtn;
/** /**
...@@ -120,6 +118,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -120,6 +118,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
// 负责流播放与推流的 View // 负责流播放与推流的 View
@property (nonatomic, strong, readonly) FUSLiveStreamView *streamView; @property (nonatomic, strong, readonly) FUSLiveStreamView *streamView;
@property (nonatomic, strong) FUSStreamPlayView *preRoomPlayView;
@property (nonatomic, strong) FUSStreamPlayView *nextRoomPlayView;
// 拉流 URL // 拉流 URL
@property (nonatomic, strong) NSString *streamURL; @property (nonatomic, strong) NSString *streamURL;
...@@ -130,23 +131,25 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -130,23 +131,25 @@ 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;
@property (nonatomic, strong) VELPictureInPictureController *pipController; @property (nonatomic, strong) VELPictureInPictureController *pipController;
/// pic in pic 启动成功回调
@property (nonatomic, copy) void(^picInPicStartedHandler)(void);
/// pic in pic 结束成功回调
@property (nonatomic, copy) void(^endPictureInPictureHandler)(BOOL restore);
@property (nonatomic, strong) UIVisualEffectView *passwordBlurView; /// 开始滑动的Y值
@property (nonatomic, assign) CGFloat beginY;
//是否已经进入房间了 /// 正在预加载的播放器
@property (nonatomic, assign) BOOL hasEnterRoom; @property (nonatomic, weak) FUSStreamPlayView *preloadingPlayView;
@end @end
@implementation FUSLiveMainViewController @implementation FUSLiveMainViewController
- (void)loadView {
self.view = [ScreenShieldView createWithFrame:UIScreen.mainScreen.bounds];
}
#pragma mark - Life Cycle #pragma mark - Life Cycle
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
...@@ -154,9 +157,11 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -154,9 +157,11 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
// Do any additional setup after loading the view from its nib. // Do any additional setup after loading the view from its nib.
[self initBackgroundView]; [self initBackgroundView];
[self fus_initContentView];
[self setupTelephoneCallback]; [self setupTelephoneCallback];
[self setupNetworkMonitor]; [self fus_monitorNetWorkStatusNotification];
[self installObservers]; [self installObservers];
...@@ -193,7 +198,10 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -193,7 +198,10 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
- (void)viewDidAppear:(BOOL)animated{ - (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated]; [super viewDidAppear:animated];
self.autoStartPictureInPicture = FUSSwiftLiveHelper.shared.autoStartPictureInPicture;
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_liveRoomViewDidAppear object:nil];
// [self fus_setupPreloadingPlayers];
FUSSwiftLiveHelper.shared.oc_liveRoomLifeCycle = FUSLiveRoomVCLifeCycleAppear; FUSSwiftLiveHelper.shared.oc_liveRoomLifeCycle = FUSLiveRoomVCLifeCycleAppear;
} }
...@@ -210,6 +218,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -210,6 +218,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
- (void)viewDidLayoutSubviews { - (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews]; [super viewDidLayoutSubviews];
_liveLoadingView.frame = CGRectMake(UIView.fus_screenW / 2 - 40, UIView.fus_screenH * (1 - 0.618) - 35, 80, 120); _liveLoadingView.frame = CGRectMake(UIView.fus_screenW / 2 - 40, UIView.fus_screenH * (1 - 0.618) - 35, 80, 120);
_liveLoadingView.center = CGPointMake(UIView.fus_screenW / 2.0f, UIView.fus_screenW / 2.0f);
} }
- (void)setupTelephoneCallback - (void)setupTelephoneCallback
...@@ -224,10 +233,24 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -224,10 +233,24 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
// 主播恢复直播 // 主播恢复直播
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(), ^{
if (FUSLiveHelper.shareInstance.roomType == OBSRoom) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (FUSSwiftSocketHelper.shared.oc_isConnect) {
[FUSSocketMessageHelper fus_socketRoomConnectWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId]];
}
});
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (FUSLiveHelper.shareInstance.liveRoomType == FUSRoomTypeLive || FUSLiveHelper.shareInstance.liveRoomType == FUSRoomTypePK) {
[weakSelf.playView fus_playWithUID:[[FUSLiveHelper.shareInstance roomInfoModel] roomId] Url:[[FUSLiveHelper.shareInstance streamModel] url]];
}
});
} else {
[weakSelf.pushView fus_restartPush]; [weakSelf.pushView fus_restartPush];
if (![FUSSocketMessageCenter isConnected]) { if (FUSSwiftSocketHelper.shared.oc_isConnect) {
[FUSSocketMessageHelper fus_socketSetControlWithUid:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId]]; [FUSSocketMessageHelper fus_socketRoomConnectWithRoomId:FUSLiveHelper.shareInstance.roomInfoModel.roomId];
} }
if (!weakSelf.isEnterBackground) { if (!weakSelf.isEnterBackground) {
...@@ -236,21 +259,23 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -236,21 +259,23 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[NSObject cancelPreviousPerformRequestsWithTarget:weakSelf selector:@selector(fus_requestChangeLiveToPushing) object:nil]; [NSObject cancelPreviousPerformRequestsWithTarget:weakSelf selector:@selector(fus_requestChangeLiveToPushing) object:nil];
[weakSelf performSelector:@selector(fus_requestChangeLiveToPushing) withObject:nil afterDelay:1]; [weakSelf performSelector:@selector(fus_requestChangeLiveToPushing) withObject:nil afterDelay:1];
} }
}
}); });
} else if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAudience) { } else if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAudience) {
//播放 //播放
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if ([FUSSocketMessageCenter isConnected]) { if ([FUSSocketMessageCenter isConnected]) {
// [FUSSocketMessageHelper fus_socketReconnect]; [FUSSocketMessageHelper fus_socketRoomConnectWithRoomId:FUSLiveHelper.shareInstance.roomInfoModel.roomId];
} else { } else {
} }
}); });
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// [weakSelf.playView fus_playLiveWithUrl:[[[FUSLiveHelper shareInstance] streamModel] url]]; if (FUSLiveHelper.shareInstance.liveRoomType == FUSRoomTypeLive || FUSLiveHelper.shareInstance.liveRoomType == FUSRoomTypePK) {
[weakSelf.playView fus_playWithUID:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId] Url:[[[FUSLiveHelper shareInstance] streamModel] url]]; [weakSelf.playView fus_playWithUID:[[FUSLiveHelper.shareInstance roomInfoModel] roomId] Url:[[FUSLiveHelper.shareInstance streamModel] url]];
}
}); });
} }
...@@ -260,29 +285,25 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -260,29 +285,25 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
FUSLogInfo(@"来电话"); FUSLogInfo(@"来电话");
if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAnchor) { if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAnchor) {
// 推流 // 推流
if (FUSLiveHelper.shareInstance.roomType == OBSRoom) {
dispatch_async(dispatch_get_main_queue(), ^{
//播放
[weakSelf.playView fus_stopWithUID:[[FUSLiveHelper.shareInstance roomInfoModel] roomId]];
});
} else {
// 主播暂时离开 // 主播暂时离开
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// [FUSSocketMessageHelper fus_socketSendLiveStatu:@"1"];
// [weakSelf.pushView fus_pausePush];
[NSObject cancelPreviousPerformRequestsWithTarget:weakSelf selector:@selector(fus_requestChangeLiveToPushing) object:nil]; [NSObject cancelPreviousPerformRequestsWithTarget:weakSelf selector:@selector(fus_requestChangeLiveToPushing) object:nil];
[FUSLiveHttpHelper fus_changeLiveStateWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId] state:@"1" success:^{ [FUSLiveHttpHelper fus_changeLiveStateWithRoomId:[[FUSLiveHelper.shareInstance roomInfoModel] roomId] state:@"1" success:nil failure:nil];
FUSLogInfo(@"");
} failure:^(NSString *msg, int code) {
FUSLogInfo(@"");
}];
}); });
}
} else if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAudience) { } else if ([FUSLiveHelper.shareInstance liveType] == FUSLiveTypeAudience) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
//播放 //播放
[weakSelf.playView fus_stopWithUID:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId]]; [weakSelf.playView fus_stopWithUID:[[FUSLiveHelper.shareInstance roomInfoModel] roomId]];
}); });
} }
} else if (call.callState == CTCallStateDialing) { } else if (call.callState == CTCallStateDialing) {
...@@ -291,11 +312,8 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -291,11 +312,8 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
}; };
} }
/** - (void)fus_monitorNetWorkStatusNotification {
检测网络状态
*/
- (void)setupNetworkMonitor
{
// 检测网络状态 // 检测网络状态
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
__block BOOL isFirst = YES; __block BOOL isFirst = YES;
...@@ -342,27 +360,40 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -342,27 +360,40 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
NSString *liveType = @"0"; NSString *liveType = @"0";
[FUSLiveHttpHelper fus_reconnectRoomWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId] livingType:liveType vdoid:[[[FUSLiveHelper shareInstance] streamModel] vdoid] success:^(FUSRoomInfoModel *roomInfoModel) { switch ([FUSSwiftLiveHelper.shared roomType]) {
[FUSSocketMessageHelper fus_socketRoomConnectWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId]]; case defaultRoom:
} failure:^(NSString *msg, int code, NSDictionary *errorDict) { liveType = @"0";
[FUSDialogView fus_showDialog:msg]; break;
}];
if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAudience) { case OBSRoom:
// [weakSelf.playView fus_reloadPlayer]; liveType = @"1";
[weakSelf.playView fus_reloadPlayerWithUID:[FUSLiveHelper shareInstance].roomInfoModel.roomId]; break;
[weakSelf.liveFunctionView fus_addPusherTipMessage:[NSString fus_localString:@"您当前正在使用3G/4G网络"] title:[NSString fus_localString:@"主播温馨提醒"]];
} else if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAnchor) {
[weakSelf.pushView fus_restartPush]; default:
[weakSelf.liveFunctionView fus_addPusherTipMessage:[NSString fus_localString:@"您当前正在3G/4G网络下直播"] title:[NSString fus_localString:@"温馨提醒"]]; break;
}
[FUSSwiftLiveHelper.shared fus_requestReconnectRoomWithNeedResp:YES];
if ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAudience) {
[self.playView fus_reloadPlayerWithUID:FUSSwiftLiveHelper.shared.roomInfoModel.roomId];
[self.liveFunctionView fus_addPusherTipMessage:[NSString fus_localString:@"您当前正在使用3G/4G网络"] title:[NSString fus_localString:@"主播温馨提醒"]];
} else if ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAnchor) {
if (FUSSwiftLiveHelper.shared.roomType == OBSRoom) {
[self.playView fus_reloadPlayerWithUID:FUSSwiftLiveHelper.shared.roomInfoModel.roomId];
} else {
[self.pushView fus_restartPush];
[self.liveFunctionView fus_addPusherTipMessage:[NSString fus_localString:@"您当前正在3G/4G网络下直播"] title:[NSString fus_localString:@"温馨提醒"]];
// 隔一下再请求 // 隔一下再请求
[NSObject cancelPreviousPerformRequestsWithTarget:weakSelf selector:@selector(fus_requestChangeLiveToPushing) object:nil]; [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fus_requestChangeLiveToPushing) object:nil];
[weakSelf performSelector:@selector(fus_requestChangeLiveToPushing) withObject:nil afterDelay:1]; [self performSelector:@selector(fus_requestChangeLiveToPushing) withObject:nil afterDelay:1];
} }
} }
}
break; break;
case AFNetworkReachabilityStatusReachableViaWiFi: case AFNetworkReachabilityStatusReachableViaWiFi:
{ {
...@@ -383,22 +414,34 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -383,22 +414,34 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
// 重连后发5555 // 重连后发5555
NSString *liveType = @"0"; NSString *liveType = @"0";
[FUSLiveHttpHelper fus_reconnectRoomWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId] livingType:liveType vdoid:[[[FUSLiveHelper shareInstance] streamModel] vdoid] success:^(FUSRoomInfoModel *roomInfoModel) { switch ([FUSSwiftLiveHelper.shared roomType]) {
[FUSSocketMessageHelper fus_socketRoomConnectWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId]]; case defaultRoom:
} failure:^(NSString *msg, int code, NSDictionary *errorDict) { liveType = @"0";
[FUSDialogView fus_showDialog:msg]; break;
}];
if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAudience) { case OBSRoom:
// [weakSelf.playView fus_reloadPlayer]; liveType = @"1";
[weakSelf.playView fus_reloadPlayerWithUID:[FUSLiveHelper shareInstance].roomInfoModel.roomId]; break;
} else if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAnchor) {
[weakSelf.pushView fus_restartPush]; default:
break;
}
[FUSSwiftLiveHelper.shared fus_requestReconnectRoomWithNeedResp:YES];
if ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAudience) {
[self.playView fus_reloadPlayerWithUID:FUSSwiftLiveHelper.shared.roomInfoModel.roomId];
} else if ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAnchor) {
if ([FUSSwiftLiveHelper.shared roomType] == OBSRoom) {
[self.playView fus_reloadPlayerWithUID:FUSSwiftLiveHelper.shared.roomInfoModel.roomId];
} else {
[self.pushView fus_restartPush];
// 隔一下再请求 // 隔一下再请求
[NSObject cancelPreviousPerformRequestsWithTarget:weakSelf selector:@selector(fus_requestChangeLiveToPushing) object:nil]; [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fus_requestChangeLiveToPushing) object:nil];
[weakSelf performSelector:@selector(fus_requestChangeLiveToPushing) withObject:nil afterDelay:1]; [self performSelector:@selector(fus_requestChangeLiveToPushing) withObject:nil afterDelay:1];
}
} }
} }
...@@ -411,17 +454,119 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -411,17 +454,119 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
}]; }];
} }
- (void)recieveJoinRoomSuccessNotification {
self.hasEnterRoom = YES;
}
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
} }
#pragma --mark 初始化 #pragma --mark 初始化
- (void)fus_initContentView
{
if (self.contentView) {
return;
}
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];
if (@available(iOS 11.0, *)) {
_scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
if (_pushPrepareView) {
[self.view bringSubviewToFront:_pushPrepareView];
}
if (FUSSwiftLiveHelper.shared.liveType == FUSLiveTypeAudience) {
if (![FUSSwiftLiveHelper nextRoomInfoModel] &&
![FUSSwiftLiveHelper preRoomInfoModel]) {
[self fus_setupScrollEnable:NO];
} else {
[self fus_setupScrollEnable:YES];
}
} else {
[self fus_setupScrollEnable:NO];
}
UIView *contentView = [[UIView alloc] initWithFrame:self.view.bounds];
contentView.y = 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 ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAudience || FUSSwiftLiveHelper.shared.liveRoomType == FUSRoomTypeLinkMic) {
if ([NSString isNull:[[FUSSwiftLiveHelper.shared roomInfoModel] face]]) {
UIImage *bgImg = [[FUSShowRoomCenterBunble imageNamed:@"live_bg"] imageByResizeToSize:CGSizeMake(500, 500)];
[_backgroundImageView fus_setImageWithImage:bgImg];
} else {
[_backgroundImageView fus_setWebImageWithSubURLString:[[FUSSwiftLiveHelper.shared roomInfoModel] face] placeholder:nil];
}
} else if ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAnchor) {
}
// 搭建上下滑动主播背景图
if ([FUSSwiftLiveHelper.shared 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:[[FUSSwiftLiveHelper preRoomInfoModel] face]]) {
UIImage *bgImg = [[FUSShowRoomCenterBunble imageNamed:@"live_bg"] imageByResizeToSize:CGSizeMake(500, 500)];
[_preBgImageView fus_setImageWithImage:bgImg];
} else {
// 模糊
[_preBgImageView fus_setWebImageWithSubURLString:[[FUSSwiftLiveHelper preRoomInfoModel] face] placeholder:nil];
// 非模糊
// [[self preBgImageView] oc_setWebImage:[FFSwiftLiveHelper preRoomInfoModel].face placeholderImage: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:[[FUSSwiftLiveHelper nextRoomInfoModel] face]]) {
UIImage *bgImg = [[FUSShowRoomCenterBunble imageNamed:@"live_bg"] imageByResizeToSize:CGSizeMake(500, 500)];
[_nextBgImageView fus_setImageWithImage:bgImg];
} else {
// 模糊
[_nextBgImageView fus_setWebImageWithSubURLString:[[FUSSwiftLiveHelper nextRoomInfoModel] face] placeholder:nil];
}
if (![FUSSwiftLiveHelper nextRoomInfoModel] &&
![FUSSwiftLiveHelper preRoomInfoModel]) {
[self fus_setupScrollEnable:NO];
}
}
}
- (void)initBackgroundView { - (void)initBackgroundView {
if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAnchor) { if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAnchor) {
...@@ -825,8 +970,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -825,8 +970,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[self.streamView fus_destroy]; [self.streamView fus_destroy];
[self.agoraHelper fus_destroy];
[self fus_dismissLoadingView]; [self fus_dismissLoadingView];
[FUSLiveHelper shareInstance].rooms = nil; [FUSLiveHelper shareInstance].rooms = nil;
...@@ -976,7 +1119,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -976,7 +1119,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[_playView fus_setVideoframeCallBackOpen:self.autoStartPictureInPicture forUid:self.playView.mainUID]; [_playView fus_setVideoframeCallBackOpen:self.autoStartPictureInPicture forUid:self.playView.mainUID];
self.hasEnterRoom = NO; // self.hasEnterRoom = NO;
} }
/** /**
...@@ -1618,38 +1761,45 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -1618,38 +1761,45 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
NSString *liveType = @"0"; NSString *liveType = @"0";
// 如果当前不在直播间,做下述处理
if ([NSString isNull:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId]]) {
return;
}
[FUSLiveHttpHelper fus_reconnectRoomWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId] livingType:liveType vdoid:[[[FUSLiveHelper shareInstance] streamModel] vdoid] success:^(FUSRoomInfoModel *roomInfoModel) { switch ([FUSSwiftLiveHelper.shared roomType]) {
[FUSSocketMessageHelper fus_socketRoomConnectWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId]]; case defaultRoom:
liveType = @"0";
if ([roomInfoModel.livestate intValue] == 1) { break;
// 暂时离开
[self fus_showLiveLoadingViewWithType:liveLoadingPause];
[self.playView fus_pauseWithUID:[FUSLiveHelper shareInstance].roomInfoModel.roomId];
}
} failure:^(NSString *msg, int code, NSDictionary *errorDict) {
[FUSDialogView fus_showDialog:msg];
}];
case OBSRoom:
liveType = @"1";
break;
if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAnchor) { default:
break;
}
NSString *roomid = [[FUSSwiftLiveHelper.shared roomInfoModel] roomId];
// 如果当前不在直播间,做下述处理
if ([NSString isNull:roomid]) {
return;
}
[FUSSwiftLiveHelper.shared fus_requestReconnectRoomWithNeedResp:YES];
if (FUSSwiftLiveHelper.shared.liveType == FUSLiveTypeAudience) {
if ([FUSSwiftLiveHelper.shared roomType] == OBSRoom) {
return;
} else {
// 隔一下再请求 // 隔一下再请求
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fus_requestChangeLiveToPushing) object:nil]; [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fus_requestChangeLiveToPushing) object:nil];
[self performSelector:@selector(fus_requestChangeLiveToPushing) withObject:nil afterDelay:1]; [self performSelector:@selector(fus_requestChangeLiveToPushing) withObject:nil afterDelay:1];
}
[self.pushView fus_restartPush]; [self.pushView fus_restartPush];
} else { }else
{
if (self.autoStartPictureInPicture && self.hasEnterRoom) { if (self.autoStartPictureInPicture) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self setupPictureInPicture]; [self setupPictureInPicture];
}); });
} }
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.liveFunctionView fus_replayGameHalfViewBgmIfNeeded];
});
} }
} }
...@@ -1671,16 +1821,20 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -1671,16 +1821,20 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[FUSLiveHelper fus_maximizeLiveCompletion:^{ [FUSLiveHelper fus_maximizeLiveCompletion:^{
}]; }];
if ([[FUSLiveHelper shareInstance] liveType] == FUSLiveTypeAnchor) { if ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAudience) {
// 播放
// [self destroyPlayPictureInPicture];
} else if ([FUSSwiftLiveHelper.shared liveType] == FUSLiveTypeAnchor) {
// 推流
if (FUSSwiftLiveHelper.shared.roomType == OBSRoom) {
} else {
// 隔一下再请求 // 隔一下再请求
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fus_requestChangeLiveToPushing) object:nil]; [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fus_requestChangeLiveToPushing) object:nil];
// 主播暂时离开 // 主播暂时离开
[FUSLiveHttpHelper fus_changeLiveStateWithRoomId:[[[FUSLiveHelper shareInstance] roomInfoModel] roomId] state:@"1" success:^{ [FUSLiveHttpHelper fus_changeLiveStateWithRoomId:[[FUSSwiftLiveHelper.shared roomInfoModel] roomId] state:@"1" success:nil failure:nil];
}
} failure:^(NSString *msg, int code) {
}];
} }
} }
...@@ -1715,16 +1869,16 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -1715,16 +1869,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;
} }
/** /**
...@@ -2195,16 +2349,16 @@ typedef NS_ENUM(NSInteger, FUSStreamState) { ...@@ -2195,16 +2349,16 @@ 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_hidePasswordBlurView { - (void)fus_hidePasswordBlurView {
[self.passwordBlurView removeFromSuperview]; // [self.passwordBlurView removeFromSuperview];
self.passwordBlurView = nil; // self.passwordBlurView = nil;
} }
#pragma mark - ScrollView Delegate #pragma mark - ScrollView Delegate
......
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
@class FUSLiveRTCData; @class FUSLiveRTCData;
typedef enum : NSInteger { typedef enum : NSInteger {
defaultRoom = 0 defaultRoom = 0,
OBSRoom = 1
} RoomType; } RoomType;
typedef NS_ENUM(NSInteger, FUSLiveJoinType) { typedef NS_ENUM(NSInteger, FUSLiveJoinType) {
......
...@@ -427,17 +427,17 @@ import RxSwift ...@@ -427,17 +427,17 @@ import RxSwift
} }
/// 镜像摄像头 /// 镜像摄像头
@objc public static func ffliveMirrorCamera() { @objc public static func fus_liveMirrorCamera() {
FUSLiveHelper.fus_liveMirrorCamera() FUSLiveHelper.fus_liveMirrorCamera()
} }
/// 镜像摄像头 /// 镜像摄像头
@objc public static func fflivePushSwitchMute() { @objc public static func fus_livePushSwitchMute() {
FUSLiveHelper.fus_livePushSwitchMute() FUSLiveHelper.fus_livePushSwitchMute()
} }
/// 获取当前静音状态 /// 获取当前静音状态
@objc public static func fflivePushMuteState() -> Bool { @objc public static func fus_livePushMuteState() -> Bool {
FUSLiveHelper.fus_livePushMuteState() FUSLiveHelper.fus_livePushMuteState()
} }
......
...@@ -78,7 +78,8 @@ ...@@ -78,7 +78,8 @@
NSString *muteImgStr = isMute ? @"live_setting_open_mic" : @"live_setting_close_mic"; NSString *muteImgStr = isMute ? @"live_setting_open_mic" : @"live_setting_close_mic";
[self showOptionalViewWithTitleArray:@[muteStr] [self showOptionalViewWithTitleArray:@[muteStr]
withImages:@[muteImgStr] withImages:@[muteImgStr]
withTypes:@[@(FUSLiveCameraMic)]]; withTypes:@[@(FUSLiveCameraMic)]
clickItem:click];
return; return;
}else if (type == FUSShowAllSetting) { }else if (type == FUSShowAllSetting) {
[self showOptionalViewWithTitleArray:@[[NSString fus_localString:@"美颜设置"], [self showOptionalViewWithTitleArray:@[[NSString fus_localString:@"美颜设置"],
...@@ -101,14 +102,16 @@ ...@@ -101,14 +102,16 @@
@(FUSFaceBeautychangeCamera), @(FUSFaceBeautychangeCamera),
@(FUSFaceBeautyTurnOnLight), @(FUSFaceBeautyTurnOnLight),
@(FUSLiveCameraMirror), @(FUSLiveCameraMirror),
@(FUSLiveSetTheme)]]; @(FUSLiveSetTheme)]
clickItem:click];
}else if(type == FUSShowFlashLineAndCamera){ }else if(type == FUSShowFlashLineAndCamera){
[self showOptionalViewWithTitleArray:@[[NSString fus_localString:@"闪光关闭"],[NSString fus_localString:@"反转镜头"]] [self showOptionalViewWithTitleArray:@[[NSString fus_localString:@"闪光关闭"],[NSString fus_localString:@"反转镜头"]]
withImages:@[@"live_icon_turnOnLine",@"live_icon_changeCamera"] withImages:@[@"live_icon_turnOnLine",@"live_icon_changeCamera"]
withTypes:@[ withTypes:@[
@(FUSFaceBeautyTurnOnLight), @(FUSFaceBeautyTurnOnLight),
@(FUSFaceBeautychangeCamera)] clickItem:click]; @(FUSFaceBeautychangeCamera)]
clickItem:click];
} }
[view addSubview:self]; [view addSubview:self];
......
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