用户信息增加VAP座驾字段,VAP播放座驾动画
This commit is contained in:
@@ -63,6 +63,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property(nonatomic, copy) NSString * roomUid;
|
||||
///用户信息中的 座驾 并不需要CarModel 映射一下吧
|
||||
@property (nonatomic,copy) NSString *carEffect;
|
||||
///座驾特效类型 0:普通, 1:VAP特效
|
||||
@property (nonatomic, assign) NSInteger otherViewType;
|
||||
///用户信息中需要用VAP播放的座驾, 映射一下
|
||||
@property (nonatomic, copy) NSString *viewUrl;
|
||||
///用户信息中的 座驾昵称 并不需要CarModel 映射一下吧
|
||||
@property (nonatomic,copy) NSString *carName;
|
||||
///用户信息中的 头饰的动画 并不需要HeadwearModel 映射一下吧
|
||||
|
@@ -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",
|
||||
|
@@ -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,47 +298,79 @@
|
||||
#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 (self.carEffectQueue.count == 0) {
|
||||
[self playCarEffect:effect];
|
||||
}
|
||||
[self.carEffectQueue addObject:effect];
|
||||
if (viewUrl.length) {
|
||||
NSDictionary * dic = @{@"otherViewType":@(otherViewType), @"viewUrl":viewUrl};
|
||||
if (self.carEffectQueue.count == 0) {
|
||||
[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];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)playCarEffect:(NSString *)carEffect {
|
||||
if (self.carEffectView.superview == nil) {
|
||||
[self.middleLevelView addSubview:self.carEffectView];
|
||||
[self.carEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self.middleLevelView);
|
||||
make.width.mas_equalTo(KScreenWidth);
|
||||
make.height.mas_equalTo(KScreenHeight);
|
||||
}];
|
||||
}
|
||||
[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) {
|
||||
|
||||
}];
|
||||
- (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) {
|
||||
make.center.mas_equalTo(self.middleLevelView);
|
||||
make.width.mas_equalTo(KScreenWidth);
|
||||
make.height.mas_equalTo(KScreenHeight);
|
||||
}];
|
||||
}
|
||||
[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 - 糖果树横幅动画
|
||||
@@ -1052,7 +1086,17 @@
|
||||
|
||||
- (void)vapWrap_viewDidFinishPlayMP4:(NSInteger)totalFrameCount view:(VAPView *)container {
|
||||
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;
|
||||
}
|
||||
|
||||
- (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];
|
||||
}
|
||||
|
@@ -206,23 +206,29 @@ 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];
|
||||
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"];
|
||||
attachment.data = att;
|
||||
NSString *sessionID = [NSString stringWithFormat:@"%ld",self.roomInfo.roomId];
|
||||
NIMMessage *message = [[NIMMessage alloc]init];
|
||||
NIMCustomObject *object = [[NIMCustomObject alloc] init];
|
||||
object.attachment = attachment;
|
||||
message.messageObject = object;
|
||||
//构造会话
|
||||
NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom];
|
||||
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
attachment.data = att;
|
||||
NSString *sessionID = [NSString stringWithFormat:@"%ld",self.roomInfo.roomId];
|
||||
NIMMessage *message = [[NIMMessage alloc]init];
|
||||
NIMCustomObject *object = [[NIMCustomObject alloc] init];
|
||||
object.attachment = attachment;
|
||||
message.messageObject = object;
|
||||
//构造会话
|
||||
NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom];
|
||||
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
|
||||
}
|
||||
|
||||
- (void)changeStageViewOnRoomUpdate {
|
||||
|
Reference in New Issue
Block a user