feat: 完成 CP 相关动效
This commit is contained in:
@@ -71,6 +71,10 @@
|
||||
|
||||
#import "LuckyGiftWinningBannerView.h"
|
||||
|
||||
#import "CPGiftBanner.h"
|
||||
#import "CPLevelUpAnimation.h"
|
||||
#import "CPBindingAnimation.h"
|
||||
|
||||
@interface XPRoomAnimationView ()<
|
||||
SVGAPlayerDelegate,
|
||||
NIMBroadcastManagerDelegate,
|
||||
@@ -170,13 +174,11 @@ HWDMP4PlayDelegate>
|
||||
|
||||
@property (nonatomic, copy) NSString *GiftDynamicEffectListPath;
|
||||
|
||||
@property (nonatomic, strong) NSMutableArray *roomLuckWinningBannerModels;
|
||||
@property (nonatomic, assign) BOOL isDisplayLuckWinningBanner;
|
||||
/// 新的特效播放队列,包括幸运礼物 banner, CP banner 和 CP 特效
|
||||
@property (nonatomic, strong) NSMutableArray *roomEffectModelsQueueV2;
|
||||
@property (nonatomic, assign) BOOL isRoomEffectV2Displaying;
|
||||
|
||||
///CP特效
|
||||
@property (nonatomic, strong) VAPView *cpVAPView;
|
||||
@property (nonatomic, strong) NetImageView *avatarLoader;
|
||||
@property (nonatomic, strong) NetImageView *cpAvatarLoader;
|
||||
@property (nonatomic, strong) AttachmentModel *cpAttachment;
|
||||
|
||||
@end
|
||||
@@ -208,7 +210,7 @@ HWDMP4PlayDelegate>
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
|
||||
_roomLuckWinningBannerModels = [NSMutableArray array];
|
||||
_roomEffectModelsQueueV2 = [NSMutableArray array];
|
||||
_GiftDynamicEffectListPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) xpSafeObjectAtIndex:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
|
||||
|
||||
}
|
||||
@@ -387,15 +389,7 @@ HWDMP4PlayDelegate>
|
||||
attachment.second == Custom_Message_Sub_Super_Gift_Winning_Coins_ALL_Room) {
|
||||
[self receiveLuckGiftBanner:attachment];
|
||||
} else if (attachment.first == CustomMessageType_CP) {
|
||||
self.cpAttachment = attachment;
|
||||
if (attachment.second == Custom_Message_Sub_CP_Gift) {
|
||||
|
||||
} else if (attachment.second == Custom_Message_Sub_CP_Upgrade) {
|
||||
|
||||
} else if (attachment.second == Custom_Message_Sub_CP_Binding) {
|
||||
[self playCPBinding];
|
||||
// {"data":{"giftUrl":"https://image.pekolive.com/I Do.png","partitionId":2,"receiverAvatar":"https://img.molistar.xyz/default_avatar_molistar.png","roomUid":3238,"senderAvatar":"https://img.molistar.xyz/default_avatar_molistar.png"},"first":64,"second":643}
|
||||
}
|
||||
[self receiveCPEvent: attachment];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -429,33 +423,56 @@ HWDMP4PlayDelegate>
|
||||
}
|
||||
|
||||
- (void)receiveLuckGiftBanner:(AttachmentModel *)attachment {
|
||||
[self.roomLuckWinningBannerModels addObject:attachment];
|
||||
if (!self.isDisplayLuckWinningBanner) {
|
||||
[self processNextLuckWinningAttachment];
|
||||
[self.roomEffectModelsQueueV2 addObject:attachment];
|
||||
if (!self.isRoomEffectV2Displaying) {
|
||||
[self processNextRoomEffectAttachment];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)processNextLuckWinningAttachment {
|
||||
- (void)processNextRoomEffectAttachment {
|
||||
// 检查队列是否有元素
|
||||
if (self.roomLuckWinningBannerModels.count == 0) {
|
||||
if (self.roomEffectModelsQueueV2.count == 0) {
|
||||
// 如果队列为空,停止处理
|
||||
self.isDisplayLuckWinningBanner = NO;
|
||||
self.isRoomEffectV2Displaying = NO;
|
||||
return;
|
||||
}
|
||||
|
||||
// 从队列中取出第一个元素并移出队列
|
||||
AttachmentModel *nextAttachment = [self.roomLuckWinningBannerModels firstObject];
|
||||
[self.roomLuckWinningBannerModels removeObjectAtIndex:0];
|
||||
AttachmentModel *nextAttachment = [self.roomEffectModelsQueueV2 firstObject];
|
||||
[self.roomEffectModelsQueueV2 removeObjectAtIndex:0];
|
||||
|
||||
// 设置为正在显示的状态
|
||||
self.isDisplayLuckWinningBanner = YES;
|
||||
self.isRoomEffectV2Displaying = YES;
|
||||
|
||||
switch (nextAttachment.second) {
|
||||
case Custom_Message_Sub_Super_Gift_Winning_Coins_ALL_Room:
|
||||
[self playLuckyWinningBanner:nextAttachment];
|
||||
break;
|
||||
case Custom_Message_Sub_CP_Gift:
|
||||
[self playCPGiftBanner:nextAttachment];
|
||||
break;
|
||||
case Custom_Message_Sub_CP_Upgrade:
|
||||
[self playCPLevelUp:nextAttachment];
|
||||
break;
|
||||
case Custom_Message_Sub_CP_Binding:
|
||||
[self playCPBinding:nextAttachment];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)playLuckyWinningBanner:(AttachmentModel *)nextAttachment {
|
||||
RoomInfoModel *roomInfo = self.delegate.getRoomInfo;
|
||||
// 执行 display 方法
|
||||
@kWeakify(self);
|
||||
[LuckyGiftWinningBannerView display:self inRoomUid:roomInfo.uid with:nextAttachment complete:^{
|
||||
[LuckyGiftWinningBannerView display:self
|
||||
inRoomUid:roomInfo.uid
|
||||
with:nextAttachment
|
||||
complete:^{
|
||||
@kStrongify(self);
|
||||
// Display 完成后,继续处理下一个
|
||||
[self processNextLuckWinningAttachment];
|
||||
[self processNextRoomEffectAttachment];
|
||||
} exitCurrentRoom:^{
|
||||
@kStrongify(self);
|
||||
[self.delegate exitRoom];
|
||||
@@ -2526,42 +2543,41 @@ HWDMP4PlayDelegate>
|
||||
}
|
||||
|
||||
#pragma mark - CP 礼物
|
||||
- (void)playCPBinding {
|
||||
[self addSubview:self.cpVAPView];
|
||||
[self.cpVAPView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self);
|
||||
make.top.mas_equalTo(146);
|
||||
make.width.mas_equalTo(KScreenWidth);
|
||||
make.height.mas_equalTo(230);
|
||||
- (void)receiveCPEvent:(AttachmentModel *)attachment {
|
||||
[self.roomEffectModelsQueueV2 addObject:attachment];
|
||||
if (!self.isRoomEffectV2Displaying) {
|
||||
[self processNextRoomEffectAttachment];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)playCPBinding:(AttachmentModel *)attachment {
|
||||
@kWeakify(self);
|
||||
[CPBindingAnimation display:self
|
||||
with:attachment
|
||||
complete:^{
|
||||
@kStrongify(self);
|
||||
[self processNextRoomEffectAttachment];
|
||||
}];
|
||||
|
||||
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"CP绑定" ofType:@"mp4"];
|
||||
[self.cpVAPView playHWDMP4:filePath delegate:self];
|
||||
}
|
||||
|
||||
//provide the content for tags, maybe text or url string ...
|
||||
- (NSString *)contentForVapTag:(NSString *)tag resource:(QGVAPSourceInfo *)info {
|
||||
NSDictionary *extraInfo = @{@"[name1]" : @"你阿妈",//self.cpAttachment.data[@"你阿妈"],
|
||||
@"[name2]" : @"你阿爸"};
|
||||
return extraInfo[tag];
|
||||
- (void)playCPGiftBanner:(AttachmentModel *)attachMent {
|
||||
@kWeakify(self);
|
||||
[CPGiftBanner display:self
|
||||
with:attachMent
|
||||
complete:^{
|
||||
@kStrongify(self);
|
||||
[self processNextRoomEffectAttachment];
|
||||
}];
|
||||
}
|
||||
|
||||
//provide image for url from tag content
|
||||
- (void)loadVapImageWithURL:(NSString *)urlStr context:(NSDictionary *)context completion:(VAPImageCompletionBlock)completionBlock {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
QGVAPSourceInfo *info = (QGVAPSourceInfo *)context[@"resource"];
|
||||
if ([info.contentTag isEqualToString:@"avatar1"] ) {
|
||||
self.avatarLoader = [[NetImageView alloc] init];
|
||||
[self.avatarLoader loadImageWithUrl:self.cpAttachment.data[@"senderAvatar"] completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
|
||||
completionBlock(image, nil, urlStr);
|
||||
}];
|
||||
} else {
|
||||
self.cpAvatarLoader = [[NetImageView alloc] init];
|
||||
[self.cpAvatarLoader loadImageWithUrl:self.cpAttachment.data[@"receiverAvatar"] completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
|
||||
completionBlock(image, nil, urlStr);
|
||||
}];
|
||||
}
|
||||
});
|
||||
- (void)playCPLevelUp:(AttachmentModel *)attachMent {
|
||||
@kWeakify(self);
|
||||
[CPLevelUpAnimation display:self
|
||||
with:attachMent
|
||||
complete:^{
|
||||
@kStrongify(self);
|
||||
[self processNextRoomEffectAttachment];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - 心愿礼物
|
||||
@@ -2599,10 +2615,6 @@ HWDMP4PlayDelegate>
|
||||
#pragma mark - HWDMP4PlayDelegate
|
||||
//即将开始播放时询问,true马上开始播放,false放弃播放
|
||||
- (BOOL)shouldStartPlayMP4:(VAPView *)container config:(QGVAPConfigModel *)config {
|
||||
if (container == self.cpVAPView) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
CGFloat width = config.info.size.width;
|
||||
CGFloat height = config.info.size.height;
|
||||
|
||||
@@ -2635,9 +2647,6 @@ HWDMP4PlayDelegate>
|
||||
} else if(container == self.luckyVapGiftEffectView) {
|
||||
[self.luckyVapGiftEffectView removeFromSuperview];
|
||||
self.luckyVapGiftEffectView = nil;
|
||||
} else if (container == self.cpVAPView) {
|
||||
[self.cpVAPView removeFromSuperview];
|
||||
self.cpVAPView = nil;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2674,11 +2683,6 @@ HWDMP4PlayDelegate>
|
||||
if (self.isLargeGiftAnimating == YES) {
|
||||
self.isLargeGiftAnimating = NO;
|
||||
}
|
||||
|
||||
if (_cpVAPView) {
|
||||
[self.cpVAPView removeFromSuperview];
|
||||
self.cpVAPView = nil;
|
||||
}
|
||||
}
|
||||
#pragma mark - PAGViewListener
|
||||
/**
|
||||
@@ -3014,13 +3018,4 @@ HWDMP4PlayDelegate>
|
||||
return _broadCastHieght;
|
||||
}
|
||||
|
||||
- (VAPView *)cpVAPView {
|
||||
if (!_cpVAPView) {
|
||||
_cpVAPView = [[VAPView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
||||
_cpVAPView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_cpVAPView.hwd_Delegate = self;
|
||||
}
|
||||
return _cpVAPView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user