用户信息增加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; @property(nonatomic, copy) NSString * roomUid;
///用户信息中的 座驾 并不需要CarModel 映射一下吧 ///用户信息中的 座驾 并不需要CarModel 映射一下吧
@property (nonatomic,copy) NSString *carEffect; @property (nonatomic,copy) NSString *carEffect;
///座驾特效类型 0普通 1VAP特效
@property (nonatomic, assign) NSInteger otherViewType;
///用户信息中需要用VAP播放的座驾, 映射一下
@property (nonatomic, copy) NSString *viewUrl;
///用户信息中的 座驾昵称 并不需要CarModel 映射一下吧 ///用户信息中的 座驾昵称 并不需要CarModel 映射一下吧
@property (nonatomic,copy) NSString *carName; @property (nonatomic,copy) NSString *carName;
///用户信息中的 头饰的动画 并不需要HeadwearModel 映射一下吧 ///用户信息中的 头饰的动画 并不需要HeadwearModel 映射一下吧

View File

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

View File

@@ -87,8 +87,10 @@
/// ///
@property (nonatomic, strong) NSMutableArray *nobleLevelUpQueue; @property (nonatomic, strong) NSMutableArray *nobleLevelUpQueue;
#pragma mark - #pragma mark -
@property (nonatomic, strong) NSMutableArray<NSString *> *carEffectQueue; @property (nonatomic, strong) NSMutableArray<NSDictionary *> *carEffectQueue;
@property (nonatomic,strong) SVGAImageView *carEffectView; @property (nonatomic,strong) SVGAImageView *carEffectView;
///VAP
@property (nonatomic, strong) QGVAPWrapView *carVapEffetView;
#pragma mark - #pragma mark -
@property (nonatomic, strong) NSMutableArray<NSDictionary *> *enterEffectQueue; @property (nonatomic, strong) NSMutableArray<NSDictionary *> *enterEffectQueue;
@property (nonatomic,strong) SVGAImageView *enterEffectView; @property (nonatomic,strong) SVGAImageView *enterEffectView;
@@ -296,47 +298,79 @@
#pragma mark - #pragma mark -
- (void)receiveDriveCarEnterRoom:(AttachmentModel *)attatchment { - (void)receiveDriveCarEnterRoom:(AttachmentModel *)attatchment {
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;} if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
NSInteger otherViewType = [attatchment.data[@"otherViewType"] integerValue];
NSString *viewUrl = attatchment.data[@"viewUrl"];
NSString * effect = attatchment.data[@"effect"]; NSString * effect = attatchment.data[@"effect"];
if (effect.length <= 0) return; if (viewUrl.length) {
if (self.carEffectQueue.count == 0) { NSDictionary * dic = @{@"otherViewType":@(otherViewType), @"viewUrl":viewUrl};
[self playCarEffect:effect]; if (self.carEffectQueue.count == 0) {
} [self playCarEffect:dic];
[self.carEffectQueue addObject:effect]; }
[self.carEffectQueue addObject:dic];
} else if(effect.length) {
NSDictionary * dic = @{@"effect":effect};
if (self.carEffectQueue.count == 0) {
[self playCarEffect:dic];
}
[self.carEffectQueue addObject:dic];
}
} }
- (void)playCarEffect:(NSString *)carEffect { - (void)playCarEffect:(NSDictionary *)effectDict {
if (self.carEffectView.superview == nil) { NSString *viewUrl = [effectDict objectForKey:@"viewUrl"];
[self.middleLevelView addSubview:self.carEffectView]; NSString *carEffect = [effectDict objectForKey:@"effect"];
[self.carEffectView mas_makeConstraints:^(MASConstraintMaker *make) { if (viewUrl.length) {
make.center.mas_equalTo(self.middleLevelView); self.carVapEffetView.hidden = NO;
make.width.mas_equalTo(KScreenWidth); if (self.carVapEffetView.superview == nil) {
make.height.mas_equalTo(KScreenHeight); [self.middleLevelView addSubview:self.carVapEffetView];
}]; [self.carVapEffetView mas_makeConstraints:^(MASConstraintMaker *make) {
} make.center.mas_equalTo(self.middleLevelView);
[self.parser parseWithURL:[NSURL URLWithString:carEffect] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { make.width.mas_equalTo(KScreenWidth);
if (videoItem != nil) { make.height.mas_equalTo(KScreenHeight);
CGFloat width = videoItem.videoSize.width; }];
CGFloat height = videoItem.videoSize.height; }
if (width > height) { [self.vapParser parseWithURL:viewUrl completionBlock:^(NSString * _Nullable videoUrl) {
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFit; if (videoUrl.length) {
} else {// [self.carVapEffetView setMute:YES];
CGFloat resizeH = KScreenWidth * height / width;// [self.carVapEffetView playHWDMP4:videoUrl repeatCount:1 delegate:self];
if (resizeH > KScreenHeight) {// }
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFill; } failureBlock:^(NSError * _Nullable error) {
} else {//
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFit; }];
} } else if (carEffect.length) {
} if (self.carEffectView.superview == nil) {
self.carEffectView.hidden = NO; [self.middleLevelView addSubview:self.carEffectView];
self.carEffectView.alpha = 1; [self.carEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
self.carEffectView.loops = 1; make.center.mas_equalTo(self.middleLevelView);
self.carEffectView.clearsAfterStop = YES; make.width.mas_equalTo(KScreenWidth);
self.carEffectView.videoItem = videoItem; make.height.mas_equalTo(KScreenHeight);
[self.carEffectView startAnimation]; }];
} }
} failureBlock:^(NSError * _Nullable error) { [self.parser parseWithURL:[NSURL URLWithString:carEffect] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
if (videoItem != nil) {
}]; CGFloat width = videoItem.videoSize.width;
CGFloat height = videoItem.videoSize.height;
if (width > height) {
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFit;
} else {//
CGFloat resizeH = KScreenWidth * height / width;//
if (resizeH > KScreenHeight) {//
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFill;
} else {//
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFit;
}
}
self.carEffectView.hidden = NO;
self.carEffectView.alpha = 1;
self.carEffectView.loops = 1;
self.carEffectView.clearsAfterStop = YES;
self.carEffectView.videoItem = videoItem;
[self.carEffectView startAnimation];
}
} failureBlock:^(NSError * _Nullable error) {
}];
}
} }
#pragma mark - #pragma mark -
@@ -1052,7 +1086,17 @@
- (void)vapWrap_viewDidFinishPlayMP4:(NSInteger)totalFrameCount view:(VAPView *)container { - (void)vapWrap_viewDidFinishPlayMP4:(NSInteger)totalFrameCount view:(VAPView *)container {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
self.vapEffetView.hidden = YES; 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; 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 { - (XPRoomGiftAnimationParser *)vapParser {
if (!_vapParser) { if (!_vapParser) {
_vapParser = [[XPRoomGiftAnimationParser alloc] init]; _vapParser = [[XPRoomGiftAnimationParser alloc] init];
@@ -1189,7 +1244,7 @@
return _nobleLevelUpQueue; return _nobleLevelUpQueue;
} }
- (NSMutableArray<NSString *> *)carEffectQueue { - (NSMutableArray<NSDictionary *> *)carEffectQueue {
if (_carEffectQueue == nil) { if (_carEffectQueue == nil) {
_carEffectQueue = [NSMutableArray array]; _carEffectQueue = [NSMutableArray array];
} }

View File

@@ -206,23 +206,29 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
} }
- (void)userEnterRoomSuccess { - (void)userEnterRoomSuccess {
if (self.userInfo.carEffect.length > 0) { AttachmentModel *attachment = [[AttachmentModel alloc]init];
AttachmentModel *attachment = [[AttachmentModel alloc]init]; attachment.first = CustomMessageType_Car_Notify;
attachment.first = CustomMessageType_Car_Notify; attachment.second = Custom_Message_Sub_Car_EnterRoom;
attachment.second = Custom_Message_Sub_Car_EnterRoom; NSMutableDictionary *att = [NSMutableDictionary dictionary];
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.carEffect forKey:@"effect"];
[att setValue:self.userInfo.nick forKey:@"nick"]; [att setValue:self.userInfo.nick forKey:@"nick"];
attachment.data = att; } else {
NSString *sessionID = [NSString stringWithFormat:@"%ld",self.roomInfo.roomId]; return;
NIMMessage *message = [[NIMMessage alloc]init]; }
NIMCustomObject *object = [[NIMCustomObject alloc] init]; attachment.data = att;
object.attachment = attachment; NSString *sessionID = [NSString stringWithFormat:@"%ld",self.roomInfo.roomId];
message.messageObject = object; NIMMessage *message = [[NIMMessage alloc]init];
// NIMCustomObject *object = [[NIMCustomObject alloc] init];
NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom]; object.attachment = attachment;
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil]; message.messageObject = object;
} //
NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
} }
- (void)changeStageViewOnRoomUpdate { - (void)changeStageViewOnRoomUpdate {