Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
pidan
/
FuSiLive
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b0a199bf
authored
Mar 07, 2026
by
suolong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复直播间麦克风问题
parent
bef7c671
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
312 additions
and
144 deletions
DevelopmentPods/FUSCommon/FUSCommon/FUSRouter/Routers/LiveRouter/FUSLivePublicDefine.h
DevelopmentPods/FUSCommon/FUSCommon/FUSRouter/Routers/LiveRouter/FUSLivePublicDefine.m
Modules/FUSShowRoomModule/FUSShowRoomModule/Features/NewLive/Main/Controller/FUSLiveMainViewController.h
Modules/FUSShowRoomModule/FUSShowRoomModule/Features/NewLive/Main/Controller/FUSLiveMainViewController.m
Modules/FUSShowRoomModule/FUSShowRoomModule/Features/NewLive/Main/Other/FUSLiveHelper.h
Modules/FUSShowRoomModule/FUSShowRoomModule/Features/NewLive/Main/Other/FUSSwiftLiveHelper.swift
Modules/FUSShowRoomModule/FUSShowRoomModule/Features/NewLive/Main/View/FunctionView/ChatInputView/FUSBottomOptionalView.m
DevelopmentPods/FUSCommon/FUSCommon/FUSRouter/Routers/LiveRouter/FUSLivePublicDefine.h
View file @
b0a199bf
...
...
@@ -260,6 +260,9 @@ NS_ASSUME_NONNULL_BEGIN
/// liveroom将要显示,用来通知一些地方需要刷新
+
(
NSString
*
)
fus_liveRoomViewWillAppear
;
/// liveroom已经显示,用来通知一些地方需要刷新
+
(
NSString
*
)
fus_liveRoomViewDidAppear
;
@end
...
...
DevelopmentPods/FUSCommon/FUSCommon/FUSRouter/Routers/LiveRouter/FUSLivePublicDefine.m
View file @
b0a199bf
...
...
@@ -425,6 +425,12 @@
return
@"fus_liveRoomViewWillAppear"
;
}
/// liveroom已经显示,用来通知一些地方需要刷新
+
(
NSString
*
)
fus_liveRoomViewDidAppear
{
return
@"fus_liveRoomViewDidAppear"
;
}
@end
@implementation
FUSLiveEventTrackParams
...
...
Modules/FUSShowRoomModule/FUSShowRoomModule/Features/NewLive/Main/Controller/FUSLiveMainViewController.h
View file @
b0a199bf
...
...
@@ -50,18 +50,14 @@ typedef enum : NSUInteger {
当前主播背景图片 ImageView
*/
@property
(
nonatomic
,
strong
)
FUSBlurImageView
*
backgroundImageView
;
// 切换直播间滚动计数,如果 = 0。则可滚动,> 0则不可滚动
@property
(
nonatomic
,
assign
)
NSInteger
scrollEnableCount
;
/**
初始化推流
*/
-
(
void
)
initPushPrepareView
;
/**
初始化视讯推流
*/
//- (void)initPrivatePushPrepareView;
/**
设置是否可以上下滑动切换包房
*/
-
(
void
)
fus_setupScrollEnable
:(
BOOL
)
enable
;
...
...
@@ -130,6 +126,11 @@ typedef enum : NSUInteger {
*/
-
(
void
)
fus_showLiveThemeView
;
/// 显示快捷发言的view
-
(
void
)
fus_showQuickChatEditView
;
/// 显示关注问候view
-
(
void
)
fus_showFollowSalutationView
;
/**
弹出推流质量的View
*/
...
...
@@ -178,7 +179,7 @@ typedef enum : NSUInteger {
-
(
NSString
*
)
fus_getLiveBitrate
;
-
(
void
)
fus_showPasswordBlurView
;
//
-
(
void
)
fus_hidePasswordBlurView
;
@end
...
...
Modules/FUSShowRoomModule/FUSShowRoomModule/Features/NewLive/Main/Controller/FUSLiveMainViewController.m
View file @
b0a199bf
...
...
@@ -36,7 +36,6 @@
// test
#import "FUSLiveHeadView.h"
#import "FUSAgoraHelper.h"
#import "VELPictureInPictureController.h"
#import <FUSFoundation/FUSFoundation-Swift.h>
...
...
@@ -61,7 +60,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
@property
(
nonatomic
,
strong
)
CTCallCenter
*
callCenter
;
@property
(
nonatomic
,
strong
)
FUSAgoraHelper
*
agoraHelper
;
@property
(
nonatomic
,
strong
)
UIButton
*
joinMicroBtn
;
/**
...
...
@@ -120,6 +118,9 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
// 负责流播放与推流的 View
@property
(
nonatomic
,
strong
,
readonly
)
FUSLiveStreamView
*
streamView
;
@property
(
nonatomic
,
strong
)
FUSStreamPlayView
*
preRoomPlayView
;
@property
(
nonatomic
,
strong
)
FUSStreamPlayView
*
nextRoomPlayView
;
// 拉流 URL
@property
(
nonatomic
,
strong
)
NSString
*
streamURL
;
...
...
@@ -130,23 +131,25 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
@property
(
nonatomic
,
assign
)
BOOL
isClickCloseBtn
;
// pk的时候,在画面下方显示的背景,防止画面还没显示出来一片黑的问题
@property
(
nonatomic
,
strong
)
FUSPKBottomUserHeaderView
*
pkHeaderView
;
//
@property (nonatomic, strong) FUSPKBottomUserHeaderView *pkHeaderView;
@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
@implementation
FUSLiveMainViewController
-
(
void
)
loadView
{
self
.
view
=
[
ScreenShieldView
createWithFrame
:
UIScreen
.
mainScreen
.
bounds
];
}
#pragma mark - Life Cycle
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
...
...
@@ -154,9 +157,11 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
// Do any additional setup after loading the view from its nib.
[
self
initBackgroundView
];
[
self
fus_initContentView
];
[
self
setupTelephoneCallback
];
[
self
setupNetworkMonitor
];
[
self
fus_monitorNetWorkStatusNotification
];
[
self
installObservers
];
...
...
@@ -193,7 +198,10 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
-
(
void
)
viewDidAppear
:
(
BOOL
)
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
;
}
...
...
@@ -210,6 +218,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
-
(
void
)
viewDidLayoutSubviews
{
[
super
viewDidLayoutSubviews
];
_liveLoadingView
.
frame
=
CGRectMake
(
UIView
.
fus_screenW
/
2
-
40
,
UIView
.
fus_screenH
*
(
1
-
0
.
618
)
-
35
,
80
,
120
);
_liveLoadingView
.
center
=
CGPointMake
(
UIView
.
fus_screenW
/
2
.
0
f
,
UIView
.
fus_screenW
/
2
.
0
f
);
}
-
(
void
)
setupTelephoneCallback
...
...
@@ -224,17 +233,32 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
// 主播恢复直播
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
1
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
[
weakSelf
.
pushView
fus_restartPush
];
if
(
!
[
FUSSocketMessageCenter
isConnected
])
{
[
FUSSocketMessageHelper
fus_socketSetControlWithUid
:[[[
FUSLiveHelper
shareInstance
]
roomInfoModel
]
roomId
]];
}
if
(
!
weakSelf
.
isEnterBackground
)
{
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
]];
}
});
// 隔一下再请求
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
weakSelf
selector
:
@selector
(
fus_requestChangeLiveToPushing
)
object
:
nil
];
[
weakSelf
performSelector
:
@selector
(
fus_requestChangeLiveToPushing
)
withObject
:
nil
afterDelay
:
1
];
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
];
if
(
FUSSwiftSocketHelper
.
shared
.
oc_isConnect
)
{
[
FUSSocketMessageHelper
fus_socketRoomConnectWithRoomId
:
FUSLiveHelper
.
shareInstance
.
roomInfoModel
.
roomId
];
}
if
(
!
weakSelf
.
isEnterBackground
)
{
// 隔一下再请求
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
weakSelf
selector
:
@selector
(
fus_requestChangeLiveToPushing
)
object
:
nil
];
[
weakSelf
performSelector
:
@selector
(
fus_requestChangeLiveToPushing
)
withObject
:
nil
afterDelay
:
1
];
}
}
});
...
...
@@ -242,15 +266,16 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
//播放
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
0
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
if
([
FUSSocketMessageCenter
isConnected
])
{
// [FUSSocketMessageHelper fus_socketReconnect
];
[
FUSSocketMessageHelper
fus_socketRoomConnectWithRoomId
:
FUSLiveHelper
.
shareInstance
.
roomInfoModel
.
roomId
];
}
else
{
}
});
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]];
[
weakSelf
.
playView
fus_playWithUID
:[[[
FUSLiveHelper
shareInstance
]
roomInfoModel
]
roomId
]
Url
:[[[
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
]];
}
});
}
...
...
@@ -260,29 +285,25 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
FUSLogInfo
(
@"来电话"
);
if
([[
FUSLiveHelper
shareInstance
]
liveType
]
==
FUSLiveTypeAnchor
)
{
// 推流
// 主播暂时离开
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
];
[
FUSLiveHttpHelper
fus_changeLiveStateWithRoomId
:[[[
FUSLiveHelper
shareInstance
]
roomInfoModel
]
roomId
]
state
:
@"1"
success
:^
{
FUSLogInfo
(
@""
);
if
(
FUSLiveHelper
.
shareInstance
.
roomType
==
OBSRoom
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
//播放
[
weakSelf
.
playView
fus_stopWithUID
:[[
FUSLiveHelper
.
shareInstance
roomInfoModel
]
roomId
]];
}
failure
:^
(
NSString
*
msg
,
int
code
)
{
FUSLogInfo
(
@""
);
});
}
else
{
// 主播暂时离开
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
0
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
}
];
}
);
}
else
if
([
[
FUSLiveHelper
shareInstance
]
liveType
]
==
FUSLiveTypeAudience
)
{
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
weakSelf
selector
:
@selector
(
fus_requestChangeLiveToPushing
)
object
:
nil
];
[
FUSLiveHttpHelper
fus_changeLiveStateWithRoomId
:[[
FUSLiveHelper
.
shareInstance
roomInfoModel
]
roomId
]
state
:
@"1"
success
:
nil
failure
:
nil
];
});
}
}
else
if
([
FUSLiveHelper
.
shareInstance
liveType
]
==
FUSLiveTypeAudience
)
{
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
)
{
...
...
@@ -291,11 +312,8 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
};
}
/**
检测网络状态
*/
-
(
void
)
setupNetworkMonitor
{
-
(
void
)
fus_monitorNetWorkStatusNotification
{
// 检测网络状态
__weak
typeof
(
self
)
weakSelf
=
self
;
__block
BOOL
isFirst
=
YES
;
...
...
@@ -342,26 +360,39 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
NSString
*
liveType
=
@"0"
;
[
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
)
{
[
FUSDialogView
fus_showDialog
:
msg
];
}];
if
([[
FUSLiveHelper
shareInstance
]
liveType
]
==
FUSLiveTypeAudience
)
{
// [weakSelf.playView fus_reloadPlayer];
[
weakSelf
.
playView
fus_reloadPlayerWithUID
:[
FUSLiveHelper
shareInstance
].
roomInfoModel
.
roomId
];
[
weakSelf
.
liveFunctionView
fus_addPusherTipMessage
:[
NSString
fus_localString
:
@"您当前正在使用3G/4G网络"
]
title
:[
NSString
fus_localString
:
@"主播温馨提醒"
]];
}
else
if
([[
FUSLiveHelper
shareInstance
]
liveType
]
==
FUSLiveTypeAnchor
)
{
switch
([
FUSSwiftLiveHelper
.
shared
roomType
])
{
case
defaultRoom
:
liveType
=
@"0"
;
break
;
case
OBSRoom
:
liveType
=
@"1"
;
break
;
default:
break
;
}
[
FUSSwiftLiveHelper
.
shared
fus_requestReconnectRoomWithNeedResp
:
YES
];
if
([
FUSSwiftLiveHelper
.
shared
liveType
]
==
FUSLiveTypeAudience
)
{
[
weakSelf
.
pushView
fus_restartPush
];
[
weakSelf
.
liveFunctionView
fus_addPusherTipMessage
:[
NSString
fus_localString
:
@"您当前正在3G/4G网络下直播"
]
title
:[
NSString
fus_localString
:
@"温馨提醒"
]];
[
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
:
self
selector
:
@selector
(
fus_requestChangeLiveToPushing
)
object
:
nil
];
[
self
performSelector
:
@selector
(
fus_requestChangeLiveToPushing
)
withObject
:
nil
afterDelay
:
1
];
}
// 隔一下再请求
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
weakSelf
selector
:
@selector
(
fus_requestChangeLiveToPushing
)
object
:
nil
];
[
weakSelf
performSelector
:
@selector
(
fus_requestChangeLiveToPushing
)
withObject
:
nil
afterDelay
:
1
];
}
}
break
;
case
AFNetworkReachabilityStatusReachableViaWiFi
:
...
...
@@ -383,22 +414,34 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
// 重连后发5555
NSString
*
liveType
=
@"0"
;
[
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
)
{
[
FUSDialogView
fus_showDialog
:
msg
];
}];
switch
([
FUSSwiftLiveHelper
.
shared
roomType
])
{
case
defaultRoom
:
liveType
=
@"0"
;
break
;
case
OBSRoom
:
liveType
=
@"1"
;
break
;
default:
break
;
}
[
FUSSwiftLiveHelper
.
shared
fus_requestReconnectRoomWithNeedResp
:
YES
];
if
([[
FUSLiveHelper
shareInstance
]
liveType
]
==
FUSLiveTypeAudience
)
{
// [weakSelf.playView fus_reloadPlayer];
[
weakSelf
.
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
)
{
[
weakSelf
.
pushView
fus_restartPush
];
if
([
FUSSwiftLiveHelper
.
shared
roomType
]
==
OBSRoom
)
{
[
self
.
playView
fus_reloadPlayerWithUID
:
FUSSwiftLiveHelper
.
shared
.
roomInfoModel
.
roomId
];
}
else
{
[
self
.
pushView
fus_restartPush
];
// 隔一下再请求
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
self
selector
:
@selector
(
fus_requestChangeLiveToPushing
)
object
:
nil
];
[
self
performSelector
:
@selector
(
fus_requestChangeLiveToPushing
)
withObject
:
nil
afterDelay
:
1
];
}
// 隔一下再请求
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
weakSelf
selector
:
@selector
(
fus_requestChangeLiveToPushing
)
object
:
nil
];
[
weakSelf
performSelector
:
@selector
(
fus_requestChangeLiveToPushing
)
withObject
:
nil
afterDelay
:
1
];
}
}
...
...
@@ -411,17 +454,119 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
}];
}
-
(
void
)
recieveJoinRoomSuccessNotification
{
self
.
hasEnterRoom
=
YES
;
}
-
(
void
)
didReceiveMemoryWarning
{
[
super
didReceiveMemoryWarning
];
// Dispose of any resources that can be recreated.
}
#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
{
if
([[
FUSLiveHelper
shareInstance
]
liveType
]
==
FUSLiveTypeAnchor
)
{
...
...
@@ -824,8 +969,6 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
_isClickCloseBtn
=
YES
;
[
self
.
streamView
fus_destroy
];
[
self
.
agoraHelper
fus_destroy
];
[
self
fus_dismissLoadingView
];
...
...
@@ -976,7 +1119,7 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
[
_playView
fus_setVideoframeCallBackOpen
:
self
.
autoStartPictureInPicture
forUid
:
self
.
playView
.
mainUID
];
self
.
hasEnterRoom
=
NO
;
//
self.hasEnterRoom = NO;
}
/**
...
...
@@ -1618,38 +1761,45 @@ typedef NS_ENUM(NSInteger, FUSStreamState) {
NSString
*
liveType
=
@"0"
;
switch
([
FUSSwiftLiveHelper
.
shared
roomType
])
{
case
defaultRoom
:
liveType
=
@"0"
;
break
;
case
OBSRoom
:
liveType
=
@"1"
;
break
;
default
:
break
;
}
NSString
*
roomid
=
[[
FUSSwiftLiveHelper
.
shared
roomInfoModel
]
roomId
];
// 如果当前不在直播间,做下述处理
if
([
NSString
isNull
:
[[[
FUSLiveHelper
shareInstance
]
roomInfoModel
]
roomId
]
])
{
if
([
NSString
isNull
:
roomid
])
{
return
;
}
[
FUSSwiftLiveHelper
.
shared
fus_requestReconnectRoomWithNeedResp
:
YES
];
[
FUSLiveHttpHelper
fus_reconnectRoomWithRoomId
:[[[
FUSLiveHelper
shareInstance
]
roomInfoModel
]
roomId
]
livingType
:
liveType
vdoid
:
[[[
FUSLiveHelper
shareInstance
]
streamModel
]
vdoid
]
success
:^
(
FUSRoomInfoModel
*
roomInfoModel
)
{
[
FUSSocketMessageHelper
fus_socketRoomConnectWithRoomId
:[[[
FUSLiveHelper
shareInstance
]
roomInfoModel
]
roomId
]];
if
([
roomInfoModel
.
livestate
intValue
]
==
1
)
{
//
暂时离开
[
self
fus_showLiveLoadingViewWithType
:
liveLoadingPause
];
[
self
.
playView
fus_pauseWithUID
:[
FUSLiveHelper
shareInstance
].
roomInfoModel
.
roomId
];
if
(
FUSSwiftLiveHelper
.
shared
.
liveType
==
FUSLiveTypeAudience
)
{
if
([
FUSSwiftLiveHelper
.
shared
roomType
]
==
OBSRoom
)
{
return
;
}
else
{
//
隔一下再请求
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
self
selector
:
@selector
(
fus_requestChangeLiveToPushing
)
object
:
nil
];
[
self
performSelector
:
@selector
(
fus_requestChangeLiveToPushing
)
withObject
:
nil
afterDelay
:
1
];
}
}
failure
:^
(
NSString
*
msg
,
int
code
,
NSDictionary
*
errorDict
)
{
[
FUSDialogView
fus_showDialog
:
msg
];
}];
if
([[
FUSLiveHelper
shareInstance
]
liveType
]
==
FUSLiveTypeAnchor
)
{
// 隔一下再请求
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
self
selector
:
@selector
(
fus_requestChangeLiveToPushing
)
object
:
nil
];
[
self
performSelector
:
@selector
(
fus_requestChangeLiveToPushing
)
withObject
:
nil
afterDelay
:
1
];
[
self
.
pushView
fus_restartPush
];
}
else
{
if
(
self
.
autoStartPictureInPicture
&&
self
.
hasEnterRoom
)
{
}
else
{
if
(
self
.
autoStartPictureInPicture
)
{
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
0
.
3
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
[
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) {
[
FUSLiveHelper
fus_maximizeLiveCompletion
:
^
{
}];
if
([
[
FUSLiveHelper
shareInstance
]
liveType
]
==
FUSLiveTypeAnchor
)
{
// 隔一下再请求
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
self
selector
:
@selector
(
fus_requestChangeLiveToPushing
)
object
:
nil
];
//
主播暂时离开
[
FUSLiveHttpHelper
fus_changeLiveStateWithRoomId
:[[[
FUSLiveHelper
shareInstance
]
roomInfoModel
]
roomId
]
state
:
@"1"
success
:^
{
if
([
FUSSwiftLiveHelper
.
shared
liveType
]
==
FUSLiveTypeAudience
)
{
// 播放
// [self destroyPlayPictureInPicture];
}
else
if
([
FUSSwiftLiveHelper
.
shared
liveType
]
==
FUSLiveTypeAnchor
)
{
//
推流
if
(
FUSSwiftLiveHelper
.
shared
.
roomType
==
OBSRoom
)
{
}
failure
:^
(
NSString
*
msg
,
int
code
)
{
}
else
{
}];
// 隔一下再请求
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
self
selector
:
@selector
(
fus_requestChangeLiveToPushing
)
object
:
nil
];
// 主播暂时离开
[
FUSLiveHttpHelper
fus_changeLiveStateWithRoomId
:[[
FUSSwiftLiveHelper
.
shared
roomInfoModel
]
roomId
]
state
:
@"1"
success
:
nil
failure
:
nil
];
}
}
}
...
...
@@ -1715,16 +1869,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;
}
/**
...
...
@@ -2195,16 +2349,16 @@ 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_hidePasswordBlurView
{
[
self
.
passwordBlurView
removeFromSuperview
];
self
.
passwordBlurView
=
nil
;
//
[self.passwordBlurView removeFromSuperview];
//
self.passwordBlurView = nil;
}
#pragma mark - ScrollView Delegate
...
...
Modules/FUSShowRoomModule/FUSShowRoomModule/Features/NewLive/Main/Other/FUSLiveHelper.h
View file @
b0a199bf
...
...
@@ -21,7 +21,8 @@
@class
FUSLiveRTCData
;
typedef
enum
:
NSInteger
{
defaultRoom
=
0
defaultRoom
=
0
,
OBSRoom
=
1
}
RoomType
;
typedef
NS_ENUM
(
NSInteger
,
FUSLiveJoinType
)
{
...
...
Modules/FUSShowRoomModule/FUSShowRoomModule/Features/NewLive/Main/Other/FUSSwiftLiveHelper.swift
View file @
b0a199bf
...
...
@@ -427,17 +427,17 @@ import RxSwift
}
/// 镜像摄像头
@objc
public
static
func
f
f
liveMirrorCamera
()
{
@objc
public
static
func
f
us_
liveMirrorCamera
()
{
FUSLiveHelper
.
fus_liveMirrorCamera
()
}
/// 镜像摄像头
@objc
public
static
func
f
f
livePushSwitchMute
()
{
@objc
public
static
func
f
us_
livePushSwitchMute
()
{
FUSLiveHelper
.
fus_livePushSwitchMute
()
}
/// 获取当前静音状态
@objc
public
static
func
f
f
livePushMuteState
()
->
Bool
{
@objc
public
static
func
f
us_
livePushMuteState
()
->
Bool
{
FUSLiveHelper
.
fus_livePushMuteState
()
}
...
...
Modules/FUSShowRoomModule/FUSShowRoomModule/Features/NewLive/Main/View/FunctionView/ChatInputView/FUSBottomOptionalView.m
View file @
b0a199bf
...
...
@@ -78,7 +78,8 @@
NSString
*
muteImgStr
=
isMute
?
@"live_setting_open_mic"
:
@"live_setting_close_mic"
;
[
self
showOptionalViewWithTitleArray
:@[
muteStr
]
withImages
:@[
muteImgStr
]
withTypes
:
@[
@
(
FUSLiveCameraMic
)]];
withTypes
:
@[
@
(
FUSLiveCameraMic
)]
clickItem
:
click
];
return
;
}
else
if
(
type
==
FUSShowAllSetting
)
{
[
self
showOptionalViewWithTitleArray
:@[[
NSString
fus_localString
:
@"美颜设置"
],
...
...
@@ -101,14 +102,16 @@
@
(
FUSFaceBeautychangeCamera
),
@
(
FUSFaceBeautyTurnOnLight
),
@
(
FUSLiveCameraMirror
),
@
(
FUSLiveSetTheme
)]];
@
(
FUSLiveSetTheme
)]
clickItem
:
click
];
}
else
if
(
type
==
FUSShowFlashLineAndCamera
){
[
self
showOptionalViewWithTitleArray
:@[[
NSString
fus_localString
:
@"闪光关闭"
],[
NSString
fus_localString
:
@"反转镜头"
]]
withImages
:@[
@"live_icon_turnOnLine"
,
@"live_icon_changeCamera"
]
withImages
:@[
@"live_icon_turnOnLine"
,
@"live_icon_changeCamera"
]
withTypes
:
@[
@
(
FUSFaceBeautyTurnOnLight
),
@
(
FUSFaceBeautychangeCamera
)]
clickItem
:
click
];
@
(
FUSFaceBeautychangeCamera
)]
clickItem
:
click
];
}
[
view
addSubview
:
self
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment