用户信息增加VAP座驾字段,VAP播放座驾动画

This commit is contained in:
chenguilong
2022-03-18 16:56:21 +08:00
committed by fengshuo
parent 87da700688
commit adf0a7ac56
4 changed files with 123 additions and 56 deletions

View File

@@ -63,6 +63,10 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, copy) NSString * roomUid;
///用户信息中的 座驾 并不需要CarModel 映射一下吧
@property (nonatomic,copy) NSString *carEffect;
///座驾特效类型 0普通 1VAP特效
@property (nonatomic, assign) NSInteger otherViewType;
///用户信息中需要用VAP播放的座驾, 映射一下
@property (nonatomic, copy) NSString *viewUrl;
///用户信息中的 座驾昵称 并不需要CarModel 映射一下吧
@property (nonatomic,copy) NSString *carName;
///用户信息中的 头饰的动画 并不需要HeadwearModel 映射一下吧

View File

@@ -18,6 +18,8 @@
/// id -> ID name -> other.name
+ (NSDictionary *)replacedKeyFromPropertyName {
return @{@"carEffect": @"carport.effect",
@"viewUrl": @"carport.viewUrl",
@"otherViewType": @"carport.otherViewType",
@"headwearEffect" : @"userHeadwear.effect",
@"headwearPic" : @"userHeadwear.pic",
@"carName": @"carport.name",

View File

@@ -87,8 +87,10 @@
///
@property (nonatomic, strong) NSMutableArray *nobleLevelUpQueue;
#pragma mark -
@property (nonatomic, strong) NSMutableArray<NSString *> *carEffectQueue;
@property (nonatomic, strong) NSMutableArray<NSDictionary *> *carEffectQueue;
@property (nonatomic,strong) SVGAImageView *carEffectView;
///VAP
@property (nonatomic, strong) QGVAPWrapView *carVapEffetView;
#pragma mark -
@property (nonatomic, strong) NSMutableArray<NSDictionary *> *enterEffectQueue;
@property (nonatomic,strong) SVGAImageView *enterEffectView;
@@ -296,15 +298,46 @@
#pragma mark -
- (void)receiveDriveCarEnterRoom:(AttachmentModel *)attatchment {
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
NSInteger otherViewType = [attatchment.data[@"otherViewType"] integerValue];
NSString *viewUrl = attatchment.data[@"viewUrl"];
NSString * effect = attatchment.data[@"effect"];
if (effect.length <= 0) return;
if (viewUrl.length) {
NSDictionary * dic = @{@"otherViewType":@(otherViewType), @"viewUrl":viewUrl};
if (self.carEffectQueue.count == 0) {
[self playCarEffect:effect];
[self playCarEffect:dic];
}
[self.carEffectQueue addObject:dic];
} else if(effect.length) {
NSDictionary * dic = @{@"effect":effect};
if (self.carEffectQueue.count == 0) {
[self playCarEffect:dic];
}
[self.carEffectQueue addObject:dic];
}
[self.carEffectQueue addObject:effect];
}
- (void)playCarEffect:(NSString *)carEffect {
- (void)playCarEffect:(NSDictionary *)effectDict {
NSString *viewUrl = [effectDict objectForKey:@"viewUrl"];
NSString *carEffect = [effectDict objectForKey:@"effect"];
if (viewUrl.length) {
self.carVapEffetView.hidden = NO;
if (self.carVapEffetView.superview == nil) {
[self.middleLevelView addSubview:self.carVapEffetView];
[self.carVapEffetView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
[self.vapParser parseWithURL:viewUrl completionBlock:^(NSString * _Nullable videoUrl) {
if (videoUrl.length) {
[self.carVapEffetView setMute:YES];
[self.carVapEffetView playHWDMP4:videoUrl repeatCount:1 delegate:self];
}
} failureBlock:^(NSError * _Nullable error) {
}];
} else if (carEffect.length) {
if (self.carEffectView.superview == nil) {
[self.middleLevelView addSubview:self.carEffectView];
[self.carEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -338,6 +371,7 @@
}];
}
}
#pragma mark -
- (void)receiveCandyTreeGiftHighLevle:(AttachmentModel *)attatchment {
@@ -1052,7 +1086,17 @@
- (void)vapWrap_viewDidFinishPlayMP4:(NSInteger)totalFrameCount view:(VAPView *)container {
dispatch_async(dispatch_get_main_queue(), ^{
if (container.superview == self.carVapEffetView) {
self.carVapEffetView.hidden = YES;
[self.carVapEffetView removeFromSuperview];
[self.carEffectQueue removeObjectAtIndex:0];
if (self.carEffectQueue.count > 0) {
[self playCarEffect:self.carEffectQueue.firstObject];
}
} else if (container.superview == self.vapEffetView) {
self.vapEffetView.hidden = YES;
}
});
}
@@ -1079,6 +1123,17 @@
return _vapEffetView;
}
- (QGVAPWrapView *)carVapEffetView {
if (!_carVapEffetView) {
_carVapEffetView = [[QGVAPWrapView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
_carVapEffetView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
_carVapEffetView.hidden = YES;
_carVapEffetView.contentMode = QGVAPWrapViewContentModeAspectFit;
_carVapEffetView.autoDestoryAfterFinish = YES;
}
return _carVapEffetView;
}
- (XPRoomGiftAnimationParser *)vapParser {
if (!_vapParser) {
_vapParser = [[XPRoomGiftAnimationParser alloc] init];
@@ -1189,7 +1244,7 @@
return _nobleLevelUpQueue;
}
- (NSMutableArray<NSString *> *)carEffectQueue {
- (NSMutableArray<NSDictionary *> *)carEffectQueue {
if (_carEffectQueue == nil) {
_carEffectQueue = [NSMutableArray array];
}

View File

@@ -206,13 +206,20 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
}
- (void)userEnterRoomSuccess {
if (self.userInfo.carEffect.length > 0) {
AttachmentModel *attachment = [[AttachmentModel alloc]init];
attachment.first = CustomMessageType_Car_Notify;
attachment.second = Custom_Message_Sub_Car_EnterRoom;
NSMutableDictionary *att = [NSMutableDictionary dictionary];
if (self.userInfo.viewUrl.length > 0) {
[att setValue:self.userInfo.nick forKey:@"nick"];
[att setValue:self.userInfo.viewUrl forKey:@"viewUrl"];
[att setValue:@(self.userInfo.otherViewType) forKey:@"otherViewType"];
} else if (self.userInfo.carEffect.length > 0) {
[att setValue:self.userInfo.carEffect forKey:@"effect"];
[att setValue:self.userInfo.nick forKey:@"nick"];
} else {
return;
}
attachment.data = att;
NSString *sessionID = [NSString stringWithFormat:@"%ld",self.roomInfo.roomId];
NIMMessage *message = [[NIMMessage alloc]init];
@@ -223,7 +230,6 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
}
}
- (void)changeStageViewOnRoomUpdate {
if (self.roomInfo.datingState == RoomDatingStateChangeType_Open && ![self.stageView isKindOfClass:[DatingStageView class]]) {