Commit 4b43dace by pidan

备份代码

parent 2f03c130
Showing with 281 additions and 145 deletions
......@@ -188,6 +188,7 @@
self.mtkView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.mtkView.backgroundColor = UIColor.clearColor;
self.mtkView.device = MTLCreateSystemDefaultDevice();
self.mtkView.colorPixelFormat = MTLPixelFormatRGBA8Unorm;
[self addSubview:self.mtkView];
self.metalRenderer = [[BDAlphaPlayerMetalRenderer alloc] initWithMetalKitView:self.mtkView];
......
......@@ -118,7 +118,7 @@
self.numVertices = sizeof(quadVertices) / sizeof(BDAlphaPlayerVertex);
}
-(void)setupPipeline
- (void)setupPipeline
{
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"BDAlphaPlayer.bundle/default" ofType:@"metallib"];
NSError *error = nil;
......@@ -132,11 +132,14 @@
pipelineStateDescriptor.colorAttachments[0].pixelFormat = self.mtkView.colorPixelFormat;
pipelineStateDescriptor.colorAttachments[0].blendingEnabled = true;
pipelineStateDescriptor.colorAttachments[0].rgbBlendOperation = MTLBlendOperationAdd;
pipelineStateDescriptor.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorOne;
pipelineStateDescriptor.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOne;
pipelineStateDescriptor.colorAttachments[0].alphaBlendOperation = MTLBlendOperationMin;
pipelineStateDescriptor.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorSourceAlpha;
pipelineStateDescriptor.colorAttachments[0].sourceAlphaBlendFactor = MTLBlendFactorOne;
pipelineStateDescriptor.colorAttachments[0].destinationAlphaBlendFactor = MTLBlendFactorOne;
pipelineStateDescriptor.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
pipelineStateDescriptor.colorAttachments[0].destinationAlphaBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
self.pipelineState = [self.mtkView.device newRenderPipelineStateWithDescriptor:pipelineStateDescriptor error:NULL];
self.commandQueue = [self.mtkView.device newCommandQueue];
}
......
......@@ -8,48 +8,55 @@
#include <metal_stdlib>
#include "BDAlphaPlayerMetalShaderType.h"
using namespace metal;
typedef struct {
// ────────────────────────────── 1. 顶点阶段 ──────────────────────────────
struct RasterizerData
{
float4 clipSpacePosition [[position]];
float2 textureCoordinate;
} RasterizerData;
};
vertex RasterizerData vertexShader(uint vertexID [[ vertex_id ]],
constant BDAlphaPlayerVertex *vertexArray [[ buffer(BDAlphaPlayerVertexInputIndexVertices) ]]) {
vertex RasterizerData vertexShader(uint vertexID [[ vertex_id ]], constant BDAlphaPlayerVertex *vertexArray [[buffer(BDAlphaPlayerVertexInputIndexVertices) ]])
{
RasterizerData out;
out.clipSpacePosition = vertexArray[vertexID].position;
out.textureCoordinate = vertexArray[vertexID].textureCoordinate;
return out;
}
fragment float4 samplingShader(RasterizerData input [[stage_in]],
texture2d<float> textureY [[ texture(BDAlphaPlayerFragmentTextureIndexTextureY) ]],
texture2d<float> textureUV [[ texture(BDAlphaPlayerFragmentTextureIndexTextureUV) ]],
constant BDAlphaPlayerConvertMatrix *convertMatrix [[ buffer(BDAlphaPlayerFragmentInputIndexMatrix) ]])
// 片元着色器
fragment float4 samplingShader(RasterizerData in [[stage_in]],
// Y / UV —— 必填
texture2d<float, access::sample> textureY [[
texture(BDAlphaPlayerFragmentTextureIndexTextureY)]],
texture2d<float, access::sample> textureUV [[texture(BDAlphaPlayerFragmentTextureIndexTextureUV)]],
// 颜色转换矩阵 (仅用于 YUV→RGB,不再给 α 用)
constant BDAlphaPlayerConvertMatrix& cvtMat [[buffer(BDAlphaPlayerFragmentInputIndexMatrix)]]
)
{
constexpr sampler textureSamplerLinear (mag_filter::linear, min_filter::linear);
constexpr sampler textureSamplerNearest (mag_filter::nearest, min_filter::nearest);
constexpr sampler s(address::clamp_to_edge, filter::linear);
// 主体颜色采样(右半边)
float2 colorTexCoord = float2(input.textureCoordinate.x / 2 + 0.5, input.textureCoordinate.y);
float yColor = textureY.sample(textureSamplerLinear, colorTexCoord).r;
float2 uvColor = textureUV.sample(textureSamplerLinear, colorTexCoord).rg;
const float split = 0.5; // 避免 0
float3 yuvColor = float3(yColor, uvColor);
float3 rgb = convertMatrix->matrix * (yuvColor + convertMatrix->offset);
// ───── 2.1 取颜色 ─────
float2 uvColor = float2(in.textureCoordinate.x * split + (1.0 - split),
in.textureCoordinate.y);
// Alpha 采样(左半边)
float2 alphaTexCoord = float2(input.textureCoordinate.x / 2, input.textureCoordinate.y);
float yAlpha = textureY.sample(textureSamplerNearest, alphaTexCoord).r;
float3 yuv = float3(textureY .sample(s, uvColor).r,
textureUV.sample(s, uvColor).rg);
// 映射 Alpha 范围
#define ALPHA_MIN 0.1
#define ALPHA_MAX 0.9
float finalAlpha = saturate((yAlpha - ALPHA_MIN) / (ALPHA_MAX - ALPHA_MIN));
float3 rgb = cvtMat.matrix * (yuv + cvtMat.offset);
return float4(rgb, finalAlpha);
}
// ───── 2.2 取 α ─────
float alpha;
float2 uvAlpha = float2(in.textureCoordinate.x * split,
in.textureCoordinate.y);
float3 yuvA = float3(textureY.sample(s, uvAlpha).r,
textureUV.sample(s, uvAlpha).rg);
// 只要 Y 分量即可;若素材 α 经过和颜色相同的编码流程,可再走一次矩阵
alpha = (cvtMat.matrix * (yuvA + cvtMat.offset)).r;
return float4(rgb, alpha);
}
......@@ -160,8 +160,8 @@ NSString *const BDAlphaPlayerErrorDomain = @"BDAlphaPlayerErrorDomain";
CGRect tt = CGRectMake(0, 0, 0, 0);
CGFloat width = superViewFrame.size.width;
CGFloat height = superViewFrame.size.height;
tt.origin.x = (openglNewRect.origin.x + 1) * width / 2;
tt.origin.y = height/2 - ceil((openglNewRect.origin.y + openglNewRect.size.height) * height / 2);
tt.origin.x = superViewFrame.origin.x + (openglNewRect.origin.x + 1) * width / 2;
tt.origin.y = superViewFrame.origin.y + height/2 - ceil((openglNewRect.origin.y + openglNewRect.size.height) * height / 2);
tt.size.width = openglNewRect.size.width / 2 * width;
tt.size.height = openglNewRect.size.height / 2 * height;
return tt;
......
......@@ -5,12 +5,12 @@
"scale" : "1x"
},
{
"filename" : "Share_icon_chat@2x.png",
"filename" : "私信@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Share_icon_chat@3x.png",
"filename" : "私信@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
......
......@@ -15,10 +15,19 @@
- (void)fus_playMotorAudioIfNeeded{
if ([self fus_needPlayAudio]) {
if ([[FUSGiftDataCenter sharedCenter] fus_checkGiftResourceExitWithURL:self.audioresource resourceMD5:nil]) {
NSString *filePath = @"";
if ([NSString isNullWithString:self.mp4Res]) {
NSString *filePath = [FUSConfig.sharedInstanced.pathConfigs downloadResourcePath:self.audioresource pathMd5:nil];
if ([[FUSGiftDataCenter sharedCenter] fus_checkGiftResourceExitWithURL:self.audioresource resourceMD5:nil]) {
filePath = [FUSConfig.sharedInstanced.pathConfigs downloadResourcePath:self.audioresource pathMd5:nil];
}
} else {
filePath = [FUSConfig.sharedInstanced.pathConfigs downloadResourcePath:self.mp4Res pathMd5:self.mp4Md5];
}
if ([NSString isNullWithString:filePath] == NO) {
[[FUSAudioHelper shareInstance] stop];
[[FUSAudioHelper shareInstance] playWithFilePath:[NSURL URLWithString:filePath] progress:^(NSTimeInterval currentTime) {
......
......@@ -82,9 +82,9 @@
#define ROOM_CID_LIKE 11003 // 点赞
#define ROOM_CID_LIVE_STATU 11004 // 直播状态改变
#define ROOM_CID_RECOMMEND_ANCHOR_LIVE_STATU 11005 // 推荐的主播直播状态
#define ROOM_CID_LIVE_SCOPE_DID_CHANGED 11017 // 切换直播范围
#define ROOM_CID_LIVE_ROOM_TYPE_CHANGED 11009 // 切换直播类型
#define ROOM_CID_BECOME_FANS_GROUP_MEMBER 11010 // 用户成为粉丝团成员
#define ROOM_CID_LIVE_SCOPE_DID_CHANGED 11017 // 切换直播范围
#define ROOM_CID_RoomPopularChanged 11019 // 人气值变化消息
#define ROOM_CID_receivePatAudience 11025 // 接收撩一撩信息的cid
#define ROOM_CID_receiveAnchorRewardChanged 11200 // fusi直播奖励数据变化
......
......@@ -710,4 +710,12 @@ unzipRelativePath:(NSString * _Nonnull)unzipRelativePath
unzipPath:(NSString *)unzipPath
succeed:(void(^)(BOOL succeed))succeed;
/**
递归逐层解析 JSON 字典数据,只针对包含需要特殊解码的中文数据
@param obj 需要解析的数据,接收包括 NSArray、NSDictionary 数据
@return 解析完成的数据,NSArray 解析成 NSArray,NSDictionary 解析成 NSDictionary
*/
+ (id)fus_parseJSONDictionaryLayerByLayerWithObject:(id)obj;
@end
......@@ -1414,6 +1414,7 @@
BEF678162C6B156600A670FB /* live_treasure_box_bg_img.png in Resources */ = {isa = PBXBuildFile; fileRef = BEF675EE2C6B156500A670FB /* live_treasure_box_bg_img.png */; };
BEF678172C6B156600A670FB /* live_userinfo_level_secrect.png in Resources */ = {isa = PBXBuildFile; fileRef = BEF675EF2C6B156500A670FB /* live_userinfo_level_secrect.png */; };
C50E4ED36D48026661F4283F /* Pods_FUSShowRoomModule.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B8B2CC1956F16144828BF43D /* Pods_FUSShowRoomModule.framework */; };
D210F35F2E0AB4F900C41733 /* live_password_room_anim.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = D210F35E2E0AB4F900C41733 /* live_password_room_anim.mp4 */; };
D2C6D57E2DFAB63200FB58E0 /* FUSLiveStartSetPasswordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2C6D57D2DFAB63200FB58E0 /* FUSLiveStartSetPasswordView.swift */; };
/* End PBXBuildFile section */
......@@ -2831,6 +2832,7 @@
BEF675ED2C6B156500A670FB /* live_pk_background_image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = live_pk_background_image.png; sourceTree = "<group>"; };
BEF675EE2C6B156500A670FB /* live_treasure_box_bg_img.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = live_treasure_box_bg_img.png; sourceTree = "<group>"; };
BEF675EF2C6B156500A670FB /* live_userinfo_level_secrect.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = live_userinfo_level_secrect.png; sourceTree = "<group>"; };
D210F35E2E0AB4F900C41733 /* live_password_room_anim.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = live_password_room_anim.mp4; sourceTree = "<group>"; };
D2C6D57D2DFAB63200FB58E0 /* FUSLiveStartSetPasswordView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FUSLiveStartSetPasswordView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -5282,6 +5284,7 @@
BEF675A22C6B156500A670FB /* Anims */ = {
isa = PBXGroup;
children = (
D210F35E2E0AB4F900C41733 /* live_password_room_anim.mp4 */,
00A66C322CCA21F500F366E9 /* PK_Cover_Animation */,
BEF675EA2C6B156500A670FB /* welcomeEnterRoom */,
BEF675DC2C6B156500A670FB /* Live_minimize_bg_anim */,
......@@ -6078,6 +6081,7 @@
BEF677E62C6B156600A670FB /* live_link_micro_request_7.png in Resources */,
00A66C442CCA21F600F366E9 /* PK_Cover_Animation_18.png in Resources */,
BEF676772C6B156600A670FB /* live_gift_item_selected_anim_7@2x.png in Resources */,
D210F35F2E0AB4F900C41733 /* live_password_room_anim.mp4 in Resources */,
BEF676072C6B156500A670FB /* 1_First_Kill_Animation_23@3x.png in Resources */,
BEF6772D2C6B156600A670FB /* PK_Progress_Bar_Light_Spot_Animation_12@2x.png in Resources */,
BEF676812C6B156600A670FB /* live_gift_item_selected_anim_17@2x.png in Resources */,
......
......@@ -130,8 +130,13 @@
FUSSocketMessageModel *messageModel = notification.object;
NSDictionary *dict = [messageModel fus_getJsonDict];
NSString *roomId = dict[@"roomId"];
if (roomId.integerValue == self.roomInfoModel.roomId.integerValue) {
NSDictionary *encryptionData = [FUSHttpHelper fus_parseJSONDictionaryLayerByLayerWithObject:dict[@"encryptionData"]];
[self.roomInfoModel.encryptionData fus_setValueWithDict:encryptionData];
NSInteger liveScope = [dict[@"mode"] integerValue];
self.roomScopeType = liveScope == 1 ? FUSLiveRoomScopeTypePassword : FUSLiveRoomScopeTypeOpen;
}
......@@ -1223,6 +1228,7 @@
} else {
[self.liveVC fus_hidePasswordBlurView];
[self.currentFunctionView fus_showPasswordAnim];
[self.roomInfoModel fus_setValueWithDict:roomInfo];
self.roomInfoModel.reminderKeys = reminderKey;
[self.currentFunctionView.chatTableView fus_addEnterRoomSystemTipMessage];
......@@ -1738,6 +1744,9 @@
#pragma mark - setter
- (void)setRoomScopeType:(FUSLiveRoomScopeType)roomScopeType {
if (_roomScopeType == roomScopeType) {
return;
}
_roomScopeType = roomScopeType;
if (self.currentFunctionView) {
[self.currentFunctionView fus_updateRoomScoreType];
......
......@@ -2226,6 +2226,10 @@
NSDictionary *params = @{@"fid":@(fid),@"cancel":@(cancel),@"password":password};
[FUSHttpHelper postRequestBinaryWithUrl:FUSShowRoomURLs.fus_URL_LIVE_CHANGE_Password params:params success:^(NSDictionary *dataDict, int code) {
if (cancel == 0) {
[FUSLiveHelper shareInstance].roomInfoModel.encryptionData.password = password;
}
[[FUSLiveHelper shareInstance].currentFunctionView fus_startRecordLiveTimeWithTime:dataDict[@"livetime"]];
if (success) {
success();
......
......@@ -239,6 +239,12 @@
[weakToolView removeFromSuperview];
[weakSelf removeFromSuperview];
if (type == FUSLiveBottomToolTypePK) {
if (FUSLiveHelper.shareInstance.roomScopeType == FUSLiveRoomScopeTypePassword) {
[FUSDialogView fus_showDialog:[NSString fus_versionLocalString:@"仅公开屋可分享"]];
return;
}
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(fus_bottomSubViewDidClickPKBtn:livePkBtnState:)]) {
[weakSelf.delegate fus_bottomSubViewDidClickPKBtn:weakSelf livePkBtnState:weakSelf.pkBtnState];
}
......@@ -309,6 +315,12 @@
// 点击分享按钮
- (void)onClickShareBtn
{
if (FUSLiveHelper.shareInstance.liveType != FUSLiveTypeAnchor
&& FUSLiveHelper.shareInstance.roomScopeType == FUSLiveRoomScopeTypePassword) {
[FUSDialogView fus_showDialog:[NSString fus_versionLocalString:@"无法分享私享屋"]];
return;
}
if (!_bgView) {
_bgView = [[FUSLiveHelper shareInstance].currentFunctionView fus_viewWithLayer:FUSLiveFunctionLayerManualPopView];
}
......
......@@ -148,18 +148,10 @@
[self initBtnsWithTypes:_allBtnTypes];
}else{
if (FUSLiveHelper.shareInstance.roomScopeType == FUSLiveRoomScopeTypePassword) {
_allBtnTypes = [NSMutableArray arrayWithArray:@[@(FUSLiveBottomToolTypeAudienceMessage),
@(FUSLiveBottomToolTypeTool),
// @(FUSLiveBottomToolTypeShare),
@(FUSLiveBottomToolTypeGift)]];
} else {
_allBtnTypes = [NSMutableArray arrayWithArray:@[@(FUSLiveBottomToolTypeAudienceMessage),
@(FUSLiveBottomToolTypeTool),
@(FUSLiveBottomToolTypeShare),
@(FUSLiveBottomToolTypeGift)]];
}
_allBtnTypes = [NSMutableArray arrayWithArray:@[@(FUSLiveBottomToolTypeAudienceMessage),
@(FUSLiveBottomToolTypeTool),
@(FUSLiveBottomToolTypeShare),
@(FUSLiveBottomToolTypeGift)]];
[self initBtnsWithTypes:_allBtnTypes];
}
......@@ -548,11 +540,7 @@
[self.roomScopeBtn setImage:image forState:UIControlStateNormal];
} else {
if (FUSLiveHelper.shareInstance.roomScopeType == FUSLiveRoomScopeTypePassword) {
[self fus_removeBtnWithType:FUSLiveBottomToolTypeShare];
} else {
[self fus_insertBtnWithType:FUSLiveBottomToolTypeShare index:self.divisionBtnType];
}
[self fus_insertBtnWithType:FUSLiveBottomToolTypeShare index:self.divisionBtnType];
[self fus_layoutBtnFrame];
}
}
......@@ -689,11 +677,7 @@
lastIndex = FUSLiveBottomToolTypeRoomScope;
}
} else {
if (FUSLiveHelper.shareInstance.roomScopeType == FUSLiveRoomScopeTypePassword) {
lastIndex = FUSLiveBottomToolTypeTool;
} else {
lastIndex = FUSLiveBottomToolTypeShare;
}
lastIndex = FUSLiveBottomToolTypeShare;
}
}
......@@ -773,11 +757,7 @@
lastIndex = FUSLiveBottomToolTypeRoomScope;
}
} else {
if (FUSLiveHelper.shareInstance.roomScopeType == FUSLiveRoomScopeTypePassword) {
lastIndex = FUSLiveBottomToolTypeTool;
} else {
lastIndex = FUSLiveBottomToolTypeShare;
}
lastIndex = FUSLiveBottomToolTypeShare;
}
[self fus_insertBtnWithType:FUSLiveBottomToolTypeInteractionGameEntrance
index:[self.allBtnTypes indexOfObject:@(lastIndex)]+1];
......@@ -804,12 +784,7 @@
_divisionBtnType = FUSLiveBottomToolTypeRoomScope;
}
}else{
if (FUSLiveHelper.shareInstance.roomScopeType == FUSLiveRoomScopeTypePassword) {
_divisionBtnType = FUSLiveBottomToolTypeTool;
} else {
_divisionBtnType = FUSLiveBottomToolTypeShare;
}
_divisionBtnType = FUSLiveBottomToolTypeShare;
}
}
......@@ -983,18 +958,10 @@
}
} else {
if (FUSLiveHelper.shareInstance.roomScopeType == FUSLiveRoomScopeTypePassword) {
_allBtnTypes = [NSMutableArray arrayWithArray:@[@(FUSLiveBottomToolTypeAudienceMessage),
@(FUSLiveBottomToolTypeTool),
// @(FUSLiveBottomToolTypeShare),
@(FUSLiveBottomToolTypeGift)]];
} else {
_allBtnTypes = [NSMutableArray arrayWithArray:@[@(FUSLiveBottomToolTypeAudienceMessage),
@(FUSLiveBottomToolTypeTool),
@(FUSLiveBottomToolTypeShare),
@(FUSLiveBottomToolTypeGift)]];
}
_allBtnTypes = [NSMutableArray arrayWithArray:@[@(FUSLiveBottomToolTypeAudienceMessage),
@(FUSLiveBottomToolTypeTool),
@(FUSLiveBottomToolTypeShare),
@(FUSLiveBottomToolTypeGift)]];
}
[self.chatTextView resetBulletsSelected];
self.chatTextView.textView.text = nil;
......
......@@ -254,6 +254,8 @@ typedef NS_ENUM(NSInteger, FUSFunctionMode) {
/// 更新直播间范围
- (void)fus_updateRoomScoreType;
- (void)fus_showPasswordAnim;
- (void)fus_setAnchorAudioClose:(BOOL)closed;
/**
......
......@@ -88,6 +88,7 @@
#import "FSRShowRoomEffectRecommondViewController.h"
#import <MediaPlayer/MediaPlayer.h>
#import <FUSBDAlphaPlayer/BDAlphaPlayer.h>
#import "FUSAudiencePopView.h"
#import "FUSPopularProgressView.h"
......@@ -107,7 +108,8 @@ UIScrollViewDelegate,
FUSLiveChatInputViewDelegate,
FUSPKHelperDeleagte,
FUSLinkMicUserListDelegate,
UIGestureRecognizerDelegate
UIGestureRecognizerDelegate,
BDAlphaPlayerMetalViewDelegate
>
#pragma mark - View Property
......@@ -170,7 +172,7 @@ UIGestureRecognizerDelegate
@property (nonatomic, strong) UIView *bulletsOriginalView;
///显示座驾的view
@property (nonatomic, strong) FUSCarEnterView *carEnterView;
@property (nonatomic, weak) FUSCarEnterView *carEnterView;
/**
主播模式 HeaderView
......@@ -335,6 +337,9 @@ UIGestureRecognizerDelegate
@property (nonatomic, strong) UIImageView *passwordRoomIconImageView;
@property (nonatomic, strong) BDAlphaPlayerMetalView *passwordAnimPlayView;
@end
@implementation FUSLiveFunctionView
......@@ -576,6 +581,7 @@ UIGestureRecognizerDelegate
*/
- (void)initActivtiyView
{
if (FUSConfig.sharedInstanced.devConfigs.appStatus) {
return;
}
......@@ -2048,6 +2054,7 @@ UIGestureRecognizerDelegate
*/
- (void)registerNotification
{
// 首先移除已有通知, 防止重复注册
[[NSNotificationCenter defaultCenter] removeObserver:self];
......@@ -2446,7 +2453,8 @@ UIGestureRecognizerDelegate
// 有资源文件,使用 webp View 显示
weakSelf.carEnterView = nil;
weakSelf.carEnterView = [[FUSCarEnterView alloc] initWithFrame:UIView.fus_screenFrame];
FUSCarEnterView *carEnterView = [[FUSCarEnterView alloc] initWithFrame:UIView.fus_screenFrame];
weakSelf.carEnterView = carEnterView;
weakSelf.carEnterView.hidden = NO;
weakSelf.carEnterView.userInteractionEnabled = NO;
......@@ -2458,7 +2466,6 @@ UIGestureRecognizerDelegate
[weakSelf.carEnterView setAnimationDidEnd:^(UIView *animatingView) {
[animatingView removeFromSuperview];
weakSelf.carEnterView = nil;
}];
[weakSelf.carEnterView setTapContentHandler:^(FUSRoomUserInfoModel * _Nonnull model) {
......@@ -4734,6 +4741,10 @@ UIGestureRecognizerDelegate
[self.passwordRoomIconImageView removeFromSuperview];
self.passwordRoomIconImageView = nil;
[self.passwordAnimPlayView stop];
[self.passwordAnimPlayView removeFromSuperview];
self.passwordAnimPlayView = nil;
[self.chatFastInputView fus_endTimer];
[self.chatFastInputView removeFromSuperview];
self.chatFastInputView = nil;
......@@ -5811,13 +5822,33 @@ UIGestureRecognizerDelegate
- (void)fus_showPasswordAnim {
[self.passwordRoomIconImageView removeFromSuperview];
if (self.passwordRoomIconImageView.superview) {
return;
}
self.passwordRoomIconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(12, self.popularView.bottom + 10, 49, 49)];
self.passwordRoomIconImageView.centerX = self.popularView.centerX;
self.passwordRoomIconImageView.image = [FUSShowRoomCenterBunble imageNamed:@"live_room_password_room_icon"];
[[self fus_viewWithLayer:FUSLiveFunctionLayerRoomInfos] addSubview:self.passwordRoomIconImageView];
[self.passwordAnimPlayView stop];
[self.passwordAnimPlayView removeFromSuperview];
self.passwordAnimPlayView = nil;
self.passwordAnimPlayView = [[BDAlphaPlayerMetalView alloc] initWithDelegate:self];
self.passwordAnimPlayView.frame = UIView.fus_screenFrame;
self.passwordAnimPlayView.contentMode = UIViewContentModeScaleToFill;
self.passwordAnimPlayView.backgroundColor = [UIColor clearColor];
[FUSLiveHelper.shareInstance.currentLiveVCView addSubview:self.passwordAnimPlayView];
NSString *animPath = [[FUSShowRoomCenterBunble bundle] pathForResource:@"live_password_room_anim" ofType:@"mp4"];
BDAlphaPlayerMetalConfiguration *configuration = [BDAlphaPlayerMetalConfiguration defaultConfiguration];
configuration.directory = animPath;
configuration.renderSuperViewFrame = UIView.fus_screenFrame;
configuration.orientation = BDAlphaPlayerOrientationPortrait;
[self.passwordAnimPlayView playWithMetalConfiguration:configuration];
}
- (void)fus_setAnchorAudioClose:(BOOL)closed {
......@@ -6065,6 +6096,18 @@ UIGestureRecognizerDelegate
}
}
#pragma mark - BDAlphaPlayerMetalViewDelegate
- (void)metalView:(BDAlphaPlayerMetalView *)metalView didFinishPlayingWithError:(NSError *)error {
[UIView animateWithDuration:.35 animations:^{
self.passwordAnimPlayView.alpha = 0;
} completion:^(BOOL finished) {
[self.passwordAnimPlayView removeFromSuperview];
self.passwordAnimPlayView = nil;
}];
}
#pragma mark - Emitter Delegate
- (nullable FUSEmitterViewCell *)cellForEmitterView:(nonnull FUSEmitterView *)emitterView
{
......
......@@ -37,6 +37,15 @@ typedef enum : NSUInteger {
/// UI回调
@property (nonatomic, copy) FUSLHULDataUpdateFinishHandler dataUpdateFinishHandler;
/// 最大的显示用户量
@property (nonatomic, assign) NSInteger maxUserCount;
/// session count
@property (nonatomic, assign) NSInteger shownSessionCount;
/// last sesseion row count
@property (nonatomic, assign) NSInteger lastSesseionRowCount;
@end
@implementation FUSLiveHeaderUserListView
......@@ -46,6 +55,7 @@ typedef enum : NSUInteger {
if (self) {
self.maxUserCount = 5;
[self initProperties];
}
return self;
......@@ -63,7 +73,7 @@ typedef enum : NSUInteger {
[_userCollectionView reloadData];
}
// 要显示整数个
CGFloat collectionViewWidth = width * 5;
CGFloat collectionViewWidth = width * self.maxUserCount;
if (collectionViewWidth > self.width - width) {
collectionViewWidth = width * 4;
}
......@@ -75,6 +85,8 @@ typedef enum : NSUInteger {
self.userCountBtn.centerY = self.userCollectionView.centerY;
self.userCountBtn.layer.cornerRadius = userCountBtnWidth / 2.0;
self.userCountBtn.layer.masksToBounds = YES;
[self fus_updateShownUserList];
[_userCollectionView reloadData];
}
/**
......@@ -134,7 +146,7 @@ typedef enum : NSUInteger {
// 要显示整数个
CGFloat collectionViewWidth = _userItemSize.width * 5;
CGFloat collectionViewWidth = _userItemSize.width * self.maxUserCount;
if (collectionViewWidth > self.width - _userItemSize.width) {
collectionViewWidth = _userItemSize.width * 4;
}
......@@ -148,7 +160,7 @@ typedef enum : NSUInteger {
_userCollectionView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
_userCollectionView.delegate = self;
_userCollectionView.dataSource = self;
[_userCollectionView registerClass:[FUSLiveUserCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
[_userCollectionView registerClass:[FUSLiveUserCollectionViewCell class] forCellWithReuseIdentifier:@"FUSLiveUserCollectionViewCell"];
_userCollectionView.backgroundColor = [UIColor clearColor];
[self addSubview:_userCollectionView];
}
......@@ -180,6 +192,7 @@ typedef enum : NSUInteger {
__weak typeof(self) weakSelf = self;
return ^(FUSLiveHeaderUserListChangedModel * _Nullable changedModel, void (^ _Nullable uireloadFinished)(void)) {
[weakSelf.userCountBtn setTitle:@(weakSelf.userListViewModel.totalRealUserCount).stringValue forState:UIControlStateNormal];
if (changedModel == nil) {
if (uireloadFinished) {
uireloadFinished();
......@@ -187,64 +200,104 @@ typedef enum : NSUInteger {
return;
}
BOOL hasChanged = NO;
if (changedModel.moveIndexPaths.count == 0
&& changedModel.insertIndexPaths.count == 0
&& changedModel.removeIndexPaths.count == 0) {
[weakSelf.userCollectionView reloadData];
hasChanged = YES;
} else {
for (NSArray<NSIndexPath *> *moveList in changedModel.moveIndexPaths) {
for (NSIndexPath *indexPath in moveList) {
if (indexPath.section < self.shownSessionCount - 1
|| (indexPath.section == self.shownSessionCount - 1
&& indexPath.row < self.lastSesseionRowCount)) {
hasChanged = YES;
break;
}
}
if (hasChanged) {
break;
}
}
if (hasChanged == NO) {
for (NSIndexPath *indexPath in changedModel.insertIndexPaths) {
if (indexPath.section < self.shownSessionCount - 1
|| (indexPath.section == self.shownSessionCount - 1
&& indexPath.row < self.lastSesseionRowCount)) {
hasChanged = YES;
break;
}
}
}
if (hasChanged == NO) {
for (NSIndexPath *indexPath in changedModel.removeIndexPaths) {
if (indexPath.section < self.shownSessionCount - 1
|| (indexPath.section == self.shownSessionCount - 1
&& indexPath.row < self.lastSesseionRowCount)) {
hasChanged = YES;
break;
}
}
}
}
if (hasChanged || weakSelf.userCollectionView.visibleCells.count == 0) {
[weakSelf fus_updateShownUserList];
[weakSelf.userCollectionView reloadData];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (uireloadFinished) {
uireloadFinished();
}
});
} else {
if (uireloadFinished) {
uireloadFinished();
}
}
};
}
} else {
if (@available(iOS 15.0, *)) {
//外层的try无法捕抓到这个block的崩溃,因为lock住的线程执行不是按顺序执行的,会出现数据源和当时锁住的状态已经不一致而崩溃
@try {
[weakSelf.userCollectionView performBatchUpdates:^{
if (changedModel.moveIndexPaths.count > 0) {
for (NSArray<NSIndexPath *> *moveList in changedModel.moveIndexPaths) {
[weakSelf.userCollectionView moveItemAtIndexPath:moveList.firstObject toIndexPath:moveList.lastObject];
}
}
if (changedModel.insertIndexPaths.count > 0) {
[weakSelf.userCollectionView insertItemsAtIndexPaths:changedModel.insertIndexPaths];
}
if (changedModel.removeIndexPaths.count > 0) {
[weakSelf.userCollectionView deleteItemsAtIndexPaths:changedModel.removeIndexPaths];
}
} completion:^(BOOL finished) {
if (uireloadFinished) {
uireloadFinished();
}
}];
} @catch (NSException *exception) {
[weakSelf initCollectionView];
if (uireloadFinished) {
uireloadFinished();
}
} @finally {
- (void)fus_updateShownUserList {
NSInteger realCount = 0;
self.shownSessionCount = self.userListViewModel.realSectionCount;
self.lastSesseionRowCount = [self.userListViewModel fus_rowNumOfSection:self.shownSessionCount - 1];
CGFloat totalWidth = 0;
for (NSInteger i = 0; i < self.userListViewModel.realSectionCount; i++) {
NSInteger rowCount = [self.userListViewModel fus_rowNumOfSection:i];
NSInteger needCount = self.maxUserCount - realCount;
if (needCount > 0) {
if (needCount > rowCount) {
realCount += rowCount;
for (NSInteger j = 0; j < rowCount; j++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
totalWidth += self.userItemSize.width;
self.lastSesseionRowCount = j + 1;
}
self.shownSessionCount = i + 1;
} else {
[weakSelf.userCollectionView reloadData];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (uireloadFinished) {
uireloadFinished();
}
});
for (NSInteger j = 0; j < needCount; j++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
totalWidth += self.userItemSize.width;
self.lastSesseionRowCount = j + 1;
}
self.shownSessionCount = i + 1;
break;
}
}
};
}
}
#pragma mark - UIScrollViewDelegate
......@@ -264,14 +317,26 @@ typedef enum : NSUInteger {
#pragma mark - UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return self.userListViewModel.sectionCount;
if (self.shownSessionCount > self.userListViewModel.realSectionCount) {
return self.userListViewModel.realSectionCount;
}
return self.shownSessionCount;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return [self.userListViewModel fus_rowNumOfSection:section];
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
NSInteger rowCount = [self.userListViewModel fus_rowNumOfSection:section];
if (section < self.shownSessionCount - 1) {
return rowCount;
} else {
if (self.lastSesseionRowCount > rowCount) {
return rowCount;
}
return self.lastSesseionRowCount;
}
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
FUSLiveUserCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
FUSLiveUserCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FUSLiveUserCollectionViewCell" forIndexPath:indexPath];
if (self.userListViewModel) {
FUSOnlineUserModel *model = [self.userListViewModel fus_userOfIndexPath:indexPath];
......
......@@ -134,6 +134,7 @@
}
- (void)dealloc{
FUSLogInfo(@"%s",__func__);
[[FUSKeyboardShowHelper sharedInstance] removeDelegate:self];
}
......@@ -206,7 +207,8 @@
BDAlphaPlayerMetalConfiguration *configuration = [BDAlphaPlayerMetalConfiguration defaultConfiguration];
configuration.directory = filePath;
configuration.renderSuperViewFrame = UIView.fus_screenFrame;
CGRect renderSuperViewFrame = weakSelf.playView.frame;
configuration.renderSuperViewFrame = renderSuperViewFrame;
configuration.orientation = BDAlphaPlayerOrientationPortrait;
[weakSelf.playView playWithMetalConfiguration:configuration];
......@@ -237,9 +239,8 @@
CGRect keyboardFrame = [FUSKeyboardShowHelper sharedInstance].keyboardFrame;
[self fus_restContentYWithKeyboardFrame:keyboardFrame withAnimate:NO];
}
if ([NSString isNullWithString:self.motorModel.mp4Res]) {
[self.motorModel fus_playMotorAudioIfNeeded];
}
[self.motorModel fus_playMotorAudioIfNeeded];
_carImageView.alpha = 0;
......@@ -304,6 +305,7 @@
[self.playView stopWithFinishPlayingCallback];
self.playView.hidden = YES;
self.playView = nil;
[self removeAllSubviews];
_animationDidEnd = nil;
......
......@@ -163,7 +163,7 @@ import RxSwift
let newPassword = self.passwordView.fus_getText()
if newPassword.count < 4 {
FUSDialogView.fus_showDialog(.fus_versionLocalString("私享屋密码必须为4位"))
FUSDialogView.fus_showDialog(.fus_versionLocalString("密码设置错误"))
} else {
if self.isAudience {
......
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