feat: 基本完成礼物支持嵌入元素功能

This commit is contained in:
P
2024-11-22 13:47:34 +08:00
parent 9fe30ce255
commit 786f15cae7
9 changed files with 352 additions and 186 deletions

View File

@@ -158,6 +158,8 @@ typedef NS_ENUM(NSUInteger, CustomMessageSubGift) {
Custom_Message_Sub_Gift_ChannelNotify = 32, Custom_Message_Sub_Gift_ChannelNotify = 32,
///发送 福袋 礼物 ///发送 福袋 礼物
Custom_Message_Sub_Gift_LuckySend = 34, Custom_Message_Sub_Gift_LuckySend = 34,
///发送 嵌入式礼物
Custom_Message_Sub_Gift_EmbeddedStyle = 35,
}; };
///first = CustomMessageType_Account ///first = CustomMessageType_Account

View File

@@ -263,7 +263,7 @@
layout.itemSize = CGSizeMake(kGetScaleWidth(88), kGetScaleWidth(88)); // item layout.itemSize = CGSizeMake(kGetScaleWidth(88), kGetScaleWidth(88)); // item
layout.minimumLineSpacing = 20; // layout.minimumLineSpacing = 20; //
if (iPhoneXSeries) { if (iPhoneXSeries) {
layout.minimumInteritemSpacing = 11.5; // layout.minimumInteritemSpacing = 10; //
} else { } else {
layout.minimumInteritemSpacing = 4; layout.minimumInteritemSpacing = 4;
} }

View File

@@ -35,7 +35,6 @@
#import "AttachmentModel.h" #import "AttachmentModel.h"
#import "XPGiftBigPrizeModel.h" #import "XPGiftBigPrizeModel.h"
#import "XPGiftBannerUserInfoModel.h" #import "XPGiftBannerUserInfoModel.h"
#import "GiftReceiveInfoModel.h"
#import "XPMessageRemoteExtModel.h" #import "XPMessageRemoteExtModel.h"
#import "DatingInfoModel.h" #import "DatingInfoModel.h"
#import "AcrossRoomPKPrizeModel.h" #import "AcrossRoomPKPrizeModel.h"
@@ -91,8 +90,7 @@ XPRoomStarKitchenBannerViewDelegate,
PAGViewListener, PAGViewListener,
XPRoomAnchorRankBannerViewDelegate, XPRoomAnchorRankBannerViewDelegate,
PIRoomGiftBroadcastWindowDelegate, PIRoomGiftBroadcastWindowDelegate,
PIUniversalBannerViewDelegate, PIUniversalBannerViewDelegate>
HWDMP4PlayDelegate>
/// ///
/// ///
@property (nonatomic,strong) XPRoomAnimationHitView * lowLevelView; @property (nonatomic,strong) XPRoomAnimationHitView * lowLevelView;
@@ -187,6 +185,11 @@ HWDMP4PlayDelegate>
///CP ///CP
@property (nonatomic, strong) AttachmentModel *cpAttachment; @property (nonatomic, strong) AttachmentModel *cpAttachment;
@property(nonatomic, strong) GiftReceiveInfoModel *mp4TempReceiveInfoModel;
@property(nonatomic, strong) NetImageView *mp4AvatarLoader_1;
@property(nonatomic, strong) NetImageView *mp4AvatarLoader_2;
@property(nonatomic, strong) NSMutableArray *embeddedTargetDatas;
@end @end
@implementation XPRoomAnimationView @implementation XPRoomAnimationView
@@ -303,9 +306,58 @@ HWDMP4PlayDelegate>
AttachmentModel *attachment = (AttachmentModel *)obj.attachment; AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_Gift) { if (attachment.first == CustomMessageType_Gift) {
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data]; GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
if (attachment.second == Custom_Message_Sub_Gift_EmbeddedStyle) {
receiveInfo.targetUid = [[attachment.data objectForKey:@"recvUserUid"] stringValue];
receiveInfo.targetNick = [attachment.data objectForKey:@"recvUserNick"];
receiveInfo.targetAvatar = [attachment.data objectForKey:@"recvUserAvatar"];
receiveInfo.avatar = [attachment.data objectForKey:@"sendUserAvatar"];
receiveInfo.nick = [attachment.data objectForKey:@"sendUserNick"];
receiveInfo.uid = [[attachment.data objectForKey:@"sendUserUid"] stringValue];
} else if (attachment.second == Custom_Message_Sub_Gift_Send) {
receiveInfo.targetUsers = @[];
NSLog(@"******************* %@", receiveInfo.targetAvatar);
}
if (!_embeddedTargetDatas) {
_embeddedTargetDatas = @[].mutableCopy;
}
receiveInfo.isLuckyBagGift = attachment.second == Custom_Message_Sub_Gift_LuckySend; receiveInfo.isLuckyBagGift = attachment.second == Custom_Message_Sub_Gift_LuckySend;
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend); receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
receiveInfo.isComboBatch = attachment.second == Custom_Message_Sub_AllMicroSend; receiveInfo.isComboBatch = attachment.second == Custom_Message_Sub_AllMicroSend;
[self receiveGiftHandleSendGiftAnimation:attachment];
if (receiveInfo.isLuckyBagGift) {
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
if (receiveInfo.viewUrl.length > 0) {
[self playLuckyGiftEffectWithVapUrl:receiveInfo.viewUrl];
} else {
NSString * svgaString = receiveInfo.luckyGiftSvgaUrl.length > 0 ? receiveInfo.luckyGiftSvgaUrl : receiveInfo.gift.luckyGiftSvgaUrl;
NSURL * luckyGiftSvgaUrl = [NSURL URLWithString:svgaString];
if (luckyGiftSvgaUrl.absoluteString.length > 0) {
[self playLuckyGiftEffect:luckyGiftSvgaUrl];
}
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (receiveInfo.gift.notifyFull) {
return;
}
[self receiveGift:receiveInfo];
});
} else {
if (receiveInfo.gift.notifyFull) {
return;
}
[self.embeddedTargetDatas insertObject:receiveInfo atIndex:0];
[self receiveGift:receiveInfo];
}
} else if (attachment.first == CustomMessageType_AllMicroSend) { //
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
receiveInfo.isComboBatch = attachment.second == Custom_Message_Sub_AllMicroSend;
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
[self receiveGiftHandleSendGiftAnimation:attachment]; [self receiveGiftHandleSendGiftAnimation:attachment];
if (receiveInfo.isLuckyBagGift) { if (receiveInfo.isLuckyBagGift) {
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;} if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
@@ -319,32 +371,15 @@ HWDMP4PlayDelegate>
} }
} }
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self receiveGift:receiveInfo]; if (receiveInfo.gift.notifyFull) {
}); return;
} else {
[self receiveGift:receiveInfo];
}
} else if (attachment.first == CustomMessageType_AllMicroSend) { //
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
receiveInfo.isComboBatch = attachment.second == Custom_Message_Sub_AllMicroSend;
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
[self receiveGiftHandleSendGiftAnimation:attachment];
if (receiveInfo.isLuckyBagGift) {
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
if (receiveInfo.viewUrl.length > 0) {
[self playLuckyGiftEffectWithVapUrl:receiveInfo.viewUrl];
} else {
NSString * svgaString = receiveInfo.luckyGiftSvgaUrl.length > 0 ? receiveInfo.luckyGiftSvgaUrl : receiveInfo.gift.luckyGiftSvgaUrl;
NSURL * luckyGiftSvgaUrl = [NSURL URLWithString:svgaString];
if (luckyGiftSvgaUrl.absoluteString.length > 0) {
[self playLuckyGiftEffect:luckyGiftSvgaUrl];
} }
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self receiveGift:receiveInfo]; [self receiveGift:receiveInfo];
}); });
} else { } else {
if (receiveInfo.gift.notifyFull) {
return;
}
[self receiveGift:receiveInfo]; [self receiveGift:receiveInfo];
} }
} else if (attachment.first == CustomMessageType_LuckyBag ) {// } else if (attachment.first == CustomMessageType_LuckyBag ) {//
@@ -1606,6 +1641,14 @@ HWDMP4PlayDelegate>
if ([self isInSudGame]) {return;} if ([self isInSudGame]) {return;}
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;} if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data]; GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
if (attachment.second == Custom_Message_Sub_Gift_EmbeddedStyle) {
receiveInfo.targetUid = [[attachment.data objectForKey:@"recvUserUid"] stringValue];
receiveInfo.targetNick = [attachment.data objectForKey:@"recvUserNick"];
receiveInfo.targetAvatar = [attachment.data objectForKey:@"recvUserAvatar"];
receiveInfo.avatar = [attachment.data objectForKey:@"sendUserAvatar"];
receiveInfo.nick = [attachment.data objectForKey:@"sendUserNick"];
receiveInfo.uid = [[attachment.data objectForKey:@"sendUserUid"] stringValue];
}
GiftInfoModel * giftInfo = receiveInfo.gift ? receiveInfo.gift : receiveInfo.giftInfo; GiftInfoModel * giftInfo = receiveInfo.gift ? receiveInfo.gift : receiveInfo.giftInfo;
if (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend || attachment.second == Custom_Message_Sub_Gift_LuckySend) { if (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend || attachment.second == Custom_Message_Sub_Gift_LuckySend) {
NSString * giftId = [NSString stringWithFormat:@"%ld", receiveInfo.luckyGiftList.giftList.firstObject.giftId]; NSString * giftId = [NSString stringWithFormat:@"%ld", receiveInfo.luckyGiftList.giftList.firstObject.giftId];
@@ -1657,7 +1700,9 @@ HWDMP4PlayDelegate>
} else { } else {
targetUids = receiveInfo.targetUids; targetUids = receiveInfo.targetUids;
if (targetUids.count <= 0) { if (targetUids.count <= 0) {
targetUids = [receiveInfo.targetUsers valueForKeyPath:@"uid"]; if (receiveInfo.targetUsers) {
targetUids = [receiveInfo.targetUsers valueForKeyPath:@"uid"];
}
if (targetUids.count <=0) { if (targetUids.count <=0) {
targetUids = @[receiveInfo.targetUid]; targetUids = @[receiveInfo.targetUid];
} }
@@ -2212,15 +2257,6 @@ HWDMP4PlayDelegate>
[self.svgaQueue addObject:receiveInfo]; [self.svgaQueue addObject:receiveInfo];
} }
} }
// if (self.animationListA.count > 0 && self.isPlayOfB == NO && self.isPlayOfA == NO) {
// [self createGiftBannerViewAnimation:self.animationListA.firstObject];
// }
// if(self.svgaQueue.count > 0 && self.isLargeGiftAnimating == NO){
// [self createGiftSvgaAnimation:self.svgaQueue.firstObject];
//
// }
if (self.giftEffectTimer == nil && self.svgaQueue.count > 0) { if (self.giftEffectTimer == nil && self.svgaQueue.count > 0) {
[self startHandleGiftEffectTimer]; [self startHandleGiftEffectTimer];
} }
@@ -2234,14 +2270,17 @@ HWDMP4PlayDelegate>
@kWeakify(self); @kWeakify(self);
dispatch_source_set_event_handler(_timer, ^{ dispatch_source_set_event_handler(_timer, ^{
@kStrongify(self) @kStrongify(self)
NSLog(@"******************* 当前队列个数: %@", @(self.svgaQueue.count));
if (self.svgaQueue.count > 0) { if (self.svgaQueue.count > 0) {
dispatch_sync(dispatch_get_main_queue(), ^{ dispatch_sync(dispatch_get_main_queue(), ^{
if(self.isLargeGiftAnimating == NO){ if(self.isLargeGiftAnimating == NO){
GiftReceiveInfoModel * receiveModel = [self.svgaQueue firstObject]; GiftReceiveInfoModel * receiveModel = [self.svgaQueue xpSafeObjectAtIndex:0];
[self createGiftSvgaAnimation:receiveModel]; if (receiveModel) {
[self.svgaQueue removeObject:receiveModel]; [self createGiftSvgaAnimation:receiveModel];
[self.svgaQueue removeObjectAtIndex:0];
NSLog(@"******************* 执行播放 %@, self.svgaQueue num: %@", receiveModel.targetAvatar, @(self.svgaQueue.count));
}
} }
}); });
}else { }else {
dispatch_source_cancel(_timer); dispatch_source_cancel(_timer);
@@ -2252,7 +2291,6 @@ HWDMP4PlayDelegate>
self.giftEffectTimer = _timer; self.giftEffectTimer = _timer;
} }
-(void)createGiftSvgaAnimation:(GiftReceiveInfoModel *)receiveInfo{ -(void)createGiftSvgaAnimation:(GiftReceiveInfoModel *)receiveInfo{
GiftInfoModel *giftInfo = receiveInfo.gift != nil ? receiveInfo.gift : receiveInfo.giftInfo; GiftInfoModel *giftInfo = receiveInfo.gift != nil ? receiveInfo.gift : receiveInfo.giftInfo;
if (!giftInfo) { if (!giftInfo) {
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo: receiveInfo.giftId]; giftInfo = [[XPGiftStorage shareStorage] findGiftInfo: receiveInfo.giftId];
@@ -2263,6 +2301,7 @@ HWDMP4PlayDelegate>
[self playGiftEffectWithPagUrl:giftInfo.viewUrl]; [self playGiftEffectWithPagUrl:giftInfo.viewUrl];
}else{ }else{
[self largeGiftStopCarEffect:giftInfo.goldPrice]; [self largeGiftStopCarEffect:giftInfo.goldPrice];
self.mp4TempReceiveInfoModel = receiveInfo;
[self playGiftEffectWithVapUrl:giftInfo.viewUrl]; [self playGiftEffectWithVapUrl:giftInfo.viewUrl];
} }
} }
@@ -2432,26 +2471,27 @@ HWDMP4PlayDelegate>
} }
[self.vapGiftEffectView setMute:NO]; [self.vapGiftEffectView setMute:NO];
[self.vapGiftEffectView playHWDMP4:vapUrl repeatCount:1 delegate:self]; [self.vapGiftEffectView playHWDMP4:vapUrl repeatCount:1 delegate:self];
return; }else {
} @kWeakify(self);
[self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) { [self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) {
if (videoUrl.length) { @kStrongify(self);
if (videoUrl.length) {
self.vapGiftEffectView.hidden = NO; self.vapGiftEffectView.hidden = NO;
if (self.vapGiftEffectView.superview == nil) { if (self.vapGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.vapGiftEffectView]; [self.middleLevelView addSubview:self.vapGiftEffectView];
[self.vapGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) { [self.vapGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView); make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth); make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight); make.height.mas_equalTo(KScreenHeight);
}]; }];
}
[self.vapGiftEffectView setMute:NO];
[self.vapGiftEffectView playHWDMP4:videoUrl repeatCount:1 delegate:self];
} }
[self.vapGiftEffectView setMute:NO]; } failureBlock:^(NSError * _Nullable error) {
[self.vapGiftEffectView playHWDMP4:videoUrl repeatCount:1 delegate:self]; self.vapGiftEffectView.hidden = YES;
} }];
} failureBlock:^(NSError * _Nullable error) { }
self.vapGiftEffectView.hidden = YES;
}];
} }
/// SVGA /// SVGA
@@ -2540,6 +2580,7 @@ HWDMP4PlayDelegate>
encodingUrl = [encodingUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; encodingUrl = [encodingUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *fileName = [[encodingUrl componentsSeparatedByString:@"/"] lastObject]; NSString *fileName = [[encodingUrl componentsSeparatedByString:@"/"] lastObject];
NSString *fullPath = [self.GiftDynamicEffectListPath stringByAppendingPathComponent:fileName]; NSString *fullPath = [self.GiftDynamicEffectListPath stringByAppendingPathComponent:fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){ if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
vapUrl = fullPath; vapUrl = fullPath;
self.luckyVapGiftEffectView.hidden = NO; self.luckyVapGiftEffectView.hidden = NO;
@@ -2553,29 +2594,29 @@ HWDMP4PlayDelegate>
} }
[self.luckyVapGiftEffectView setMute:NO]; [self.luckyVapGiftEffectView setMute:NO];
[self.luckyVapGiftEffectView playHWDMP4:vapUrl repeatCount:1 delegate:self]; [self.luckyVapGiftEffectView playHWDMP4:vapUrl repeatCount:1 delegate:self];
return; } else {
} @kWeakify(self);
[self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) { [self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) {
if (videoUrl.length) { @kStrongify(self);
self.luckyVapGiftEffectView.hidden = NO; if (videoUrl.length) {
if (self.luckyVapGiftEffectView.superview == nil) { self.luckyVapGiftEffectView.hidden = NO;
[self.middleLevelView addSubview:self.luckyVapGiftEffectView]; if (self.luckyVapGiftEffectView.superview == nil) {
[self.luckyVapGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) { [self.middleLevelView addSubview:self.luckyVapGiftEffectView];
make.center.mas_equalTo(self.middleLevelView); [self.luckyVapGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(KScreenWidth); make.center.mas_equalTo(self.middleLevelView);
make.height.mas_equalTo(KScreenHeight); make.width.mas_equalTo(KScreenWidth);
}]; make.height.mas_equalTo(KScreenHeight);
}];
}
[self.luckyVapGiftEffectView setMute:NO];
[self.luckyVapGiftEffectView playHWDMP4:videoUrl repeatCount:1 delegate:self];
} }
[self.luckyVapGiftEffectView setMute:NO]; } failureBlock:^(NSError * _Nullable error) {
[self.luckyVapGiftEffectView playHWDMP4:videoUrl repeatCount:1 delegate:self]; self.luckyVapGiftEffectView.hidden = YES;
} }];
} failureBlock:^(NSError * _Nullable error) { }
self.luckyVapGiftEffectView.hidden = YES;
}];
} }
#pragma mark - #pragma mark -
- (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player { - (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player {
if (player == self.giftEffectView) { if (player == self.giftEffectView) {
@@ -2680,7 +2721,6 @@ HWDMP4PlayDelegate>
}]; }];
} }
[self.wishGiftEffectView mas_updateConstraints:^(MASConstraintMaker *make) { [self.wishGiftEffectView mas_updateConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(x); make.leading.mas_equalTo(x);
make.top.mas_equalTo(y); make.top.mas_equalTo(y);
@@ -2726,6 +2766,7 @@ HWDMP4PlayDelegate>
} else if (container == self.vapGiftEffectView) { } else if (container == self.vapGiftEffectView) {
[self.vapGiftEffectView removeFromSuperview]; [self.vapGiftEffectView removeFromSuperview];
self.vapGiftEffectView = nil; self.vapGiftEffectView = nil;
self.mp4TempReceiveInfoModel = nil;
if (self.isLargeGiftAnimating == YES) { if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO; self.isLargeGiftAnimating = NO;
} }
@@ -2751,10 +2792,10 @@ HWDMP4PlayDelegate>
} else if (container == self.vapGiftEffectView) { } else if (container == self.vapGiftEffectView) {
[self.vapGiftEffectView removeFromSuperview]; [self.vapGiftEffectView removeFromSuperview];
self.vapGiftEffectView = nil; self.vapGiftEffectView = nil;
self.mp4TempReceiveInfoModel = nil;
if (self.isLargeGiftAnimating == YES) { if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO; self.isLargeGiftAnimating = NO;
} }
} else if(container == self.luckyVapGiftEffectView) { } else if(container == self.luckyVapGiftEffectView) {
[self.luckyVapGiftEffectView removeFromSuperview]; [self.luckyVapGiftEffectView removeFromSuperview];
self.luckyVapGiftEffectView = nil; self.luckyVapGiftEffectView = nil;
@@ -2768,7 +2809,76 @@ HWDMP4PlayDelegate>
if (self.isLargeGiftAnimating == YES) { if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO; self.isLargeGiftAnimating = NO;
} }
self.mp4TempReceiveInfoModel = nil;
} }
- (void)loadVapImageWithURL:(NSString *)urlStr context:(NSDictionary *)context completion:(VAPImageCompletionBlock)completionBlock {
if (self.mp4TempReceiveInfoModel) {
dispatch_async(dispatch_get_main_queue(), ^{
QGVAPSourceInfo *info = (QGVAPSourceInfo *)context[@"resource"];
if ([info.contentTag isEqualToString:@"avatar1"]) {
if ([NSString isEmpty:self.mp4TempReceiveInfoModel.avatar]) {
completionBlock(kImage(@"common_avatar"), nil, @"dafeult image");
} else {
NSString *path = @"";
switch (self.mp4TempReceiveInfoModel.gift.showAvatarType) {
case 1: // 使 avatar
case 3:
path = self.mp4TempReceiveInfoModel.avatar;
break;
case 2: // 使 target avatar
path = self.mp4TempReceiveInfoModel.targetAvatar;
break;
default:
completionBlock(kImage(@"common_avatar"), nil, @"dafeult image");
return;
break;
}
self.mp4AvatarLoader_1 = [[NetImageView alloc] init];
[self.mp4AvatarLoader_1 loadImageWithUrl:path completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
completionBlock(image, nil, urlStr);
}];
}
}
else if ([info.contentTag isEqualToString:@"avatar2"] ) {
GiftReceiveInfoModel *infoModel = self.mp4TempReceiveInfoModel;// [self.embeddedTargetDatas lastObject];
if (!infoModel || [NSString isEmpty:infoModel.targetAvatar]) {
completionBlock(kImage(@"common_avatar"), nil, @"dafeult image");
} else {
self.mp4AvatarLoader_2 = [[NetImageView alloc] init];
[self.mp4AvatarLoader_2 loadImageWithUrl:infoModel.targetAvatar completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
completionBlock(image, nil, urlStr);
}];
}
} else {
completionBlock(nil, nil, @"completionBlock");
}
});
}
}
- (NSString *)contentForVapTag:(NSString *)tag resource:(QGVAPSourceInfo *)info {
NSString *name1 = @"";
switch (self.mp4TempReceiveInfoModel.gift.showAvatarType) {
case 1: // 使 avatar
case 3:
name1 = self.mp4TempReceiveInfoModel.nick;
break;
case 2: // 使 target avatar
name1 = self.mp4TempReceiveInfoModel.targetNick;
break;
default:
break;
}
NSDictionary *extraInfo = @{@"name1" : [NSString isEmpty:name1] ? @"" : name1,
@"name2" : [NSString isEmpty:self.mp4TempReceiveInfoModel.targetNick] ? @"" : self.mp4TempReceiveInfoModel.targetNick,
// @"id1" : [NSString isEmpty:self.mp4TempReceiveInfoModel.uid] ? @"" : self.mp4TempReceiveInfoModel.uid ,
// @"id2" : [NSString isEmpty:infoModel.targetUid] ? @"" : infoModel.targetUid
};
return [NSString isEmpty:extraInfo[tag]] ? @" " : extraInfo[tag];
}
#pragma mark - PAGViewListener #pragma mark - PAGViewListener
/** /**
* Notifies the beginning of the animation. It can be called from either the UI thread or the thread * Notifies the beginning of the animation. It can be called from either the UI thread or the thread

View File

@@ -32,6 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface GiftComboManager : NSObject @interface GiftComboManager : NSObject
@property (nonatomic, strong) GiftReceiveInfoModel *sendGiftReceiveInfo; @property (nonatomic, strong) GiftReceiveInfoModel *sendGiftReceiveInfo;
@property(nonatomic, copy) void(^handleComboSuccess)(GiftReceiveInfoModel *receiveModel, NSMutableDictionary *originDic);
// 单例方法 // 单例方法
+ (instancetype)sharedManager; + (instancetype)sharedManager;

View File

@@ -483,10 +483,21 @@
- (void)handleSendGiftSuccess:(GiftReceiveInfoModel *)receive - (void)handleSendGiftSuccess:(GiftReceiveInfoModel *)receive
sourceData:(BaseModel *)response { sourceData:(BaseModel *)response {
// self.combo += 1;
if (self.actionCallback) { if (self.actionCallback) {
self.actionCallback(ComboAction_Combo_Count_Update); self.actionCallback(ComboAction_Combo_Count_Update);
} }
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:response.data];
[dic setObject:@(self.combo) forKey:@"comboCount"];
if (self.handleComboSuccess) {
self.handleComboSuccess(receive, dic);
}
return;
self.sendGiftReceiveInfo = receive; self.sendGiftReceiveInfo = receive;
if (self.actionCallback) { if (self.actionCallback) {
self.actionCallback(ComboAction_Update_After_Send_Success); self.actionCallback(ComboAction_Update_After_Send_Success);
@@ -533,8 +544,6 @@
[attachment.data setObject:@(self.combo) forKey:@"comboCount"]; [attachment.data setObject:@(self.combo) forKey:@"comboCount"];
[self sendCustomMessage:attachment]; [self sendCustomMessage:attachment];
} }
self.combo += 1;
} }
- (void)sendCustomMessage:(AttachmentModel *)attachment { - (void)sendCustomMessage:(AttachmentModel *)attachment {

View File

@@ -131,6 +131,9 @@ typedef NS_ENUM(NSUInteger, RoomSendGiftType) {
@property (nonatomic, strong) i18nGiftNameMap *i18nGiftNameMap; @property (nonatomic, strong) i18nGiftNameMap *i18nGiftNameMap;
@property(nonatomic, assign) NSInteger showAvatarType; // 是否需要塞头像0-否1-送礼者2-收礼者3-左送右收
@property(nonatomic, assign) BOOL notifyFull; // 该礼物动画是否全房间播放
@end @end
@interface GiftPanelTabModel : PIBaseModel @interface GiftPanelTabModel : PIBaseModel
@@ -144,6 +147,8 @@ typedef NS_ENUM(NSUInteger, RoomSendGiftType) {
@property (nonatomic, copy) NSArray <GiftInfoModel *> *gifts; @property (nonatomic, copy) NSArray <GiftInfoModel *> *gifts;
- (GiftType)tabGiftType; - (GiftType)tabGiftType;
@end @end

View File

@@ -56,12 +56,12 @@ NS_ASSUME_NONNULL_BEGIN
///目标的昵称 ///目标的昵称
@property (nonatomic,copy) NSString *targetNick; @property (nonatomic,copy) NSString *targetNick;
@property (nonatomic,strong) NSArray<NSNumber *> *targetUids; @property (nonatomic,strong) NSArray<NSNumber *> *targetUids;
///礼物信息 ///礼物信息 - 来自礼物 API
@property (nonatomic,strong) GiftInfoModel *gift; @property (nonatomic,strong) GiftInfoModel *gift;
///礼物信息 ///礼物信息
@property (nonatomic,strong) GiftInfoModel *giftInfo; @property (nonatomic,strong) GiftInfoModel *giftInfo;
///送礼物的人uid ///送礼物的人uid
@property(nonatomic, assign)NSString * uid; @property(nonatomic, assign)NSString *uid;
///礼物的id ///礼物的id
@property (nonatomic,copy) NSString *giftId; @property (nonatomic,copy) NSString *giftId;
///送礼物的人 ///送礼物的人
@@ -135,7 +135,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) NSInteger receiveGiftNumberUser; @property (nonatomic, assign) NSInteger receiveGiftNumberUser;
@property (nonatomic, assign) NSInteger bgLevel; /// 1,2,3 对应非 VIP 背景456 对应 VIP 背景 @property (nonatomic, assign) NSInteger bgLevel; // 1,2,3 对应非 VIP 背景456 对应 VIP 背景
- (NSInteger)receiveUserCount; - (NSInteger)receiveUserCount;

View File

@@ -283,119 +283,149 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
} }
} }
- (void)sendCustomMessage:(GiftReceiveInfoModel *)receiveModel oringinDic:(NSDictionary *)originDic { - (void)sendCustomMessage:(GiftReceiveInfoModel *)receiveModel
oringinDic:(NSDictionary *)originDic {
NSDictionary * dict = originDic; NSDictionary * dict = originDic;
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data addEntriesFromDictionary:dict];
if (receiveModel.roomSendGiftType == RoomSendGiftType_AllMic) { // if (receiveModel.roomSendGiftType == RoomSendGiftType_AllMic) { //
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data addEntriesFromDictionary:dict];
if (receiveModel.gift.giftType == GiftType_Lucky) { // if (receiveModel.gift.giftType == GiftType_Lucky) { //
NSArray *luckyBagGifts = (NSArray *)[data objectForKey:@"luckyBagGifts"]; [self sendLuckyBagGifts:receiveModel
data:data
if (luckyBagGifts.count >0) { firstType:CustomMessageType_AllMicroSend
for (int i = 0; i < luckyBagGifts.count; i++) { secondType:Custom_Message_Sub_AllMicroLuckySend
NSMutableDictionary * data1 = [NSMutableDictionary dictionary]; isToOne:NO];
[data1 addEntriesFromDictionary:dict];
AttachmentModel * attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_AllMicroSend;
attachment.second = Custom_Message_Sub_AllMicroLuckySend;
NSDictionary * obj = [luckyBagGifts xpSafeObjectAtIndex:i];
[data1 setObject:i == 0 ? @(YES):@(NO) forKey:@"isShowAnimation"];
[data1 setObject:obj forKey:@"luckyGiftList"];
[data1 setObject:receiveModel.gift.giftName forKey:@"giftName"];
[data1 setObject:[obj valueForKeyPath:@"user.uid"] forKey:@"targetUid"];
[data1 setObject:[dict valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
if ([dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"]) {
[data1 setObject:[dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"] forKey:@"luckyGiftSvgaUrl"];
}
[data1 removeObjectForKey:@"luckyBagGifts"];
[data1 removeObjectForKey:@"targetUsers"];
[data1 removeObjectForKey:@"gift"];
attachment.data = data1;
[self sendCustomMessage:attachment];
}
}
}else { // }else { //
AttachmentModel * attachment = [[AttachmentModel alloc] init]; if (receiveModel.gift.showAvatarType > 0) {
attachment.first = CustomMessageType_AllMicroSend; [self handleEmbeddedValueGiftsMessage:receiveModel
attachment.second = Custom_Message_Sub_AllMicroSend; oringinDic:data
[data setObject:[dict valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"]; isToOne:NO];
attachment.data = data; } else {
[self sendCustomMessage:attachment]; [self sendGiftToAllMessage:data];
}
} }
} else if (receiveModel.roomSendGiftType == RoomSendGiftType_MutableOnMic) { // } else if (receiveModel.roomSendGiftType == RoomSendGiftType_MutableOnMic) { //
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data addEntriesFromDictionary:dict];
if (receiveModel.gift.giftType == GiftType_Lucky) { // if (receiveModel.gift.giftType == GiftType_Lucky) { //
NSArray *luckyBagGifts = (NSArray *)[data objectForKey:@"luckyBagGifts"]; [self sendLuckyBagGifts:receiveModel
if (luckyBagGifts.count >0) { data:data
// firstType:CustomMessageType_AllMicroSend
[luckyBagGifts enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { secondType:Custom_Message_Sub_AllBatchMicroLuckySend
NSMutableDictionary * data1 = [NSMutableDictionary dictionary]; isToOne:NO];
[data1 addEntriesFromDictionary:dict]; } else { //
AttachmentModel * attachment = [[AttachmentModel alloc] init]; if (receiveModel.gift.showAvatarType > 0) {
attachment.first = CustomMessageType_AllMicroSend; [self handleEmbeddedValueGiftsMessage:receiveModel
attachment.second = Custom_Message_Sub_AllBatchMicroLuckySend; oringinDic:data
[data1 setObject:idx == 0 ? @(YES):@(NO) forKey:@"isShowAnimation"]; isToOne:NO];
[data1 setObject:obj forKey:@"luckyGiftList"]; } else {
[data1 setObject:receiveModel.gift.giftName forKey:@"giftName"]; [self sendGiftToMultipleMessage:data];
[data1 setObject:[obj valueForKeyPath:@"user.uid"] forKey:@"targetUid"]; }
[data1 setObject:[dict valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
if ([dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"]) {
[data1 setObject:[dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"] forKey:@"luckyGiftSvgaUrl"];
}
[data1 removeObjectForKey:@"luckyBagGifts"];
[data1 removeObjectForKey:@"targetUsers"];
attachment.data = data1;
[self sendCustomMessage:attachment];
}];
}
}else { //
AttachmentModel *attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_AllMicroSend;
attachment.second = Custom_Message_Sub_AllBatchSend;
attachment.data = data;
[self sendCustomMessage:attachment];
} }
} else if (receiveModel.roomSendGiftType == RoomSendGiftType_ToOne) { // } else if (receiveModel.roomSendGiftType == RoomSendGiftType_ToOne) { //
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data addEntriesFromDictionary:dict];
if (receiveModel.gift.giftType == GiftType_Lucky) { // if (receiveModel.gift.giftType == GiftType_Lucky) { //
NSArray *luckyBagGifts = (NSArray *)[data objectForKey:@"luckyBagGifts"]; [self sendLuckyBagGifts:receiveModel
[luckyBagGifts enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { data:data
NSMutableDictionary * data1 = [NSMutableDictionary dictionary]; firstType:CustomMessageType_Gift
[data1 addEntriesFromDictionary:dict]; secondType:Custom_Message_Sub_Gift_LuckySend
AttachmentModel * attachment = [[AttachmentModel alloc] init]; isToOne:NO];
attachment.first = CustomMessageType_Gift;
attachment.second = Custom_Message_Sub_Gift_LuckySend;
[data1 setObject:idx == 0 ? @(YES):@(NO) forKey:@"isShowAnimation"];
[data1 setObject:obj forKey:@"luckyGiftList"];
[data1 setObject:receiveModel.gift.giftName forKey:@"giftName"];
[data1 setObject:[obj valueForKeyPath:@"user.uid"] forKey:@"targetUid"];
[data1 setObject:[obj valueForKeyPath:@"user.nick"] forKey:@"targetNick"];
[data1 setObject:[dict valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
if ([dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"]) {
[data1 setObject:[dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"] forKey:@"luckyGiftSvgaUrl"];
}
[data1 removeObjectForKey:@"luckyBagGifts"];
[data1 removeObjectForKey:@"targetUsers"];
attachment.data = data1;
[self sendCustomMessage:attachment];
}];
}else { // }else { //
AttachmentModel *attachment = [[AttachmentModel alloc] init]; if (receiveModel.gift.showAvatarType > 0) {
attachment.first = CustomMessageType_Gift; [self handleEmbeddedValueGiftsMessage:receiveModel
attachment.second = Custom_Message_Sub_Gift_Send; oringinDic:data
NSDictionary *targetUsers = ((NSArray *)[data objectForKey:@"targetUsers"]).firstObject; isToOne:YES];
[data setObject:[targetUsers valueForKeyPath:@"uid"] forKey:@"targetUid"]; } else {
[data setObject:[targetUsers valueForKeyPath:@"nick"] forKey:@"targetNick"]; [self sendGiftToOneMessage:data];
[data setObject:[targetUsers valueForKeyPath:@"avatar"] forKey:@"targetAvatar"]; }
attachment.data = data;
[self sendCustomMessage:attachment];
} }
} }
} }
- (void)handleEmbeddedValueGiftsMessage:(GiftReceiveInfoModel *)receiveModel
oringinDic:(NSMutableDictionary *)data
isToOne:(BOOL)isToOne {
// second = 31
@kWeakify(self);
NSArray *targetUsers = [data objectForKey:@"targetUsers"];
__block NSTimeInterval delay = 0.0;
for (NSDictionary *obj in targetUsers) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@kStrongify(self);
AttachmentModel *attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_Gift;
attachment.second = Custom_Message_Sub_Gift_Send;
[data setObject:[[obj objectForKey:@"uid"] stringValue] forKey:@"targetUid"];
[data setObject:[obj objectForKey:@"nick"] forKey:@"targetNick"];
[data setObject:[obj objectForKey:@"avatar"] forKey:@"targetAvatar"];
[data removeObjectForKey:@"targetUsers"];
attachment.data = data;
[self sendCustomMessage:attachment];
});
delay += 0.1;
}
}
- (void)sendGiftToOneMessage:(NSMutableDictionary *)data {
AttachmentModel *attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_Gift;
attachment.second = Custom_Message_Sub_Gift_Send;
NSDictionary *targetUsers = ((NSArray *)[data objectForKey:@"targetUsers"]).firstObject;
[data setObject:[targetUsers valueForKeyPath:@"uid"] forKey:@"targetUid"];
[data setObject:[targetUsers valueForKeyPath:@"nick"] forKey:@"targetNick"];
[data setObject:[targetUsers valueForKeyPath:@"avatar"] forKey:@"targetAvatar"];
attachment.data = data;
[self sendCustomMessage:attachment];
}
- (void)sendGiftToMultipleMessage:(NSMutableDictionary *)data {
AttachmentModel *attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_AllMicroSend;
attachment.second = Custom_Message_Sub_AllBatchSend;
attachment.data = data.copy;
[self sendCustomMessage:attachment];
}
- (void)sendGiftToAllMessage:(NSMutableDictionary *)data {
AttachmentModel * attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_AllMicroSend;
attachment.second = Custom_Message_Sub_AllMicroSend;
[data setObject:[data valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
attachment.data = data;
[self sendCustomMessage:attachment];
}
- (void)sendLuckyBagGifts:(GiftReceiveInfoModel *)receiveModel
data:(NSMutableDictionary *)data
firstType:(NSUInteger)first
secondType:(NSUInteger)second
isToOne:(BOOL)isToOne {
@kWeakify(self);
NSArray *luckyBagGifts = (NSArray *)[data objectForKey:@"luckyBagGifts"];
[luckyBagGifts enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
@kStrongify(self);
NSMutableDictionary *tempData = [NSMutableDictionary dictionaryWithDictionary:data.copy];
AttachmentModel * attachment = [[AttachmentModel alloc] init];
attachment.first = (int)first;
attachment.second = (int)second;
[tempData setObject:idx == 0 ? @(YES):@(NO) forKey:@"isShowAnimation"];
[tempData setObject:obj forKey:@"luckyGiftList"];
[tempData setObject:receiveModel.gift.giftName forKey:@"giftName"];
[tempData setObject:[obj valueForKeyPath:@"user.uid"] forKey:@"targetUid"];
if (isToOne) {
[tempData setObject:[obj valueForKeyPath:@"user.nick"] forKey:@"targetNick"];
}
[tempData setObject:[data valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
if ([tempData valueForKeyPath:@"gift.luckyGiftSvgaUrl"]) {
[tempData setObject:[data valueForKeyPath:@"gift.luckyGiftSvgaUrl"] forKey:@"luckyGiftSvgaUrl"];
}
attachment.data = tempData;
[self sendCustomMessage:attachment];
}];
}
- (void)sendCustomMessage:(AttachmentModel *)attachment { - (void)sendCustomMessage:(AttachmentModel *)attachment {
NSString *sessionID = self.usingplaceType == SendGiftType_User ? [NSString stringWithFormat:@"%ld", self.userArray.firstObject.uid] : [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].roomId]; NSString *sessionID = self.usingplaceType == SendGiftType_User ? [NSString stringWithFormat:@"%ld", self.userArray.firstObject.uid] : [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].roomId];
NIMMessage *message = [[NIMMessage alloc]init]; NIMMessage *message = [[NIMMessage alloc]init];
@@ -881,7 +911,9 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
} }
} }
- (void)sendGiftSuccess:(GiftReceiveInfoModel *)receiveInfo originDic:(NSDictionary *)originDic uidCount:(NSInteger)uidCount{ - (void)sendGiftSuccess:(GiftReceiveInfoModel *)receiveInfo
originDic:(NSDictionary *)originDic
uidCount:(NSInteger)uidCount{
self.giftBarView.sendButtonIsEnable = YES; self.giftBarView.sendButtonIsEnable = YES;
if (receiveInfo.sourceType == GiftSourceType_Pack) { if (receiveInfo.sourceType == GiftSourceType_Pack) {
/// ///
@@ -896,6 +928,11 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
@kStrongify(self); @kStrongify(self);
if (self) { if (self) {
[[GiftComboManager sharedManager] resetCombo]; [[GiftComboManager sharedManager] resetCombo];
@kWeakify(self);
[[GiftComboManager sharedManager] setHandleComboSuccess:^(GiftReceiveInfoModel * _Nonnull receiveModel, NSMutableDictionary * _Nonnull originDic) {
@kStrongify(self);
[self sendCustomMessage:receiveInfo oringinDic:originDic.copy];
}];
[self sendCustomMessage:receiveInfo oringinDic:originDic]; [self sendCustomMessage:receiveInfo oringinDic:originDic];
} }
}); });

View File

@@ -2122,6 +2122,8 @@ XPCandyTreeInsufficientBalanceViewDelegate>
// //
- (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error { - (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error {
NSLog(@"******************* sendMessage Raw Attach Content: %@, %ld", [[(AttachmentModel *)[(NIMCustomObject *)message.messageObject attachment] data] objectForKey:@"targetAvatar"], (long)message.messageType);
if (message.yidunAntiSpamRes) { if (message.yidunAntiSpamRes) {
NSDictionary * spamRes = message.yidunAntiSpamRes.toJSONObject; NSDictionary * spamRes = message.yidunAntiSpamRes.toJSONObject;
id spamResExt = ((NSString *)spamRes[@"ext"]).toJSONObject; id spamResExt = ((NSString *)spamRes[@"ext"]).toJSONObject;