修复bug

This commit is contained in:
liyuhua
2023-08-30 17:35:45 +08:00
parent fbc75cabb5
commit 4e0dce479d

View File

@@ -89,7 +89,8 @@
@property (strong,nonatomic)NSMutableSet * bannerDequePool;
///
@property (strong,nonatomic)NSMutableSet * bannerVisiablePool;
/// 6s
@property (nonatomic,strong)dispatch_source_t giftEffectTimer;
#pragma mark -
@@ -152,6 +153,15 @@
- (void)dealloc {
[NSObject cancelPreviousPerformRequestsWithTarget:self];
[[NIMSDK sharedSDK].broadcastManager removeDelegate:self];
if(self.giftEffectTimer != nil){
dispatch_resume(self.giftEffectTimer);
self.giftEffectTimer = nil;
}
if(self.giftTimer != nil){
dispatch_resume(self.giftTimer);
self.giftEffectTimer = nil;
}
}
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
@@ -1628,13 +1638,37 @@
// [self createGiftBannerViewAnimation:self.animationListA.firstObject];
// }
if(self.svgaQueue.count > 0 && self.isLargeGiftAnimating == NO){
[self createGiftSvgaAnimation:self.svgaQueue.firstObject];
// if(self.svgaQueue.count > 0 && self.isLargeGiftAnimating == NO){
// [self createGiftSvgaAnimation:self.svgaQueue.firstObject];
//
// }
if (self.giftEffectTimer == nil && self.svgaQueue.count > 0) {
[self startHandleGiftEffectTimer];
}
}
///
- (void)startHandleGiftEffectTimer {
NSTimeInterval period = 6.0; // 6 1svga 2.svga 3
dispatch_queue_t queue = dispatch_get_global_queue(0, 0);
dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(_timer, dispatch_walltime(NULL, 0), period * NSEC_PER_SEC, 0); //
@kWeakify(self);
dispatch_source_set_event_handler(_timer, ^{
@kStrongify(self)
if (self.svgaQueue.count > 0) {
dispatch_sync(dispatch_get_main_queue(), ^{
GiftReceiveInfoModel * receiveModel = [self.svgaQueue firstObject];
[self createGiftBannerViewAnimation:receiveModel];
[self.svgaQueue removeObject:receiveModel];
});
}else {
dispatch_source_cancel(_timer);
self.giftEffectTimer = nil;
}
});
dispatch_resume(_timer);
self.giftEffectTimer = _timer;
}
-(void)createGiftSvgaAnimation:(GiftReceiveInfoModel *)receiveInfo{
GiftInfoModel *giftInfo = receiveInfo.gift != nil ? receiveInfo.gift : receiveInfo.giftInfo;
@@ -1649,9 +1683,7 @@
[self largeGiftStopCarEffect:giftInfo.goldPrice];
[self playGiftEffect:giftInfo.vggUrl];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
});
}
- (void)createGiftBannerViewAnimation:(GiftReceiveInfoModel *)receiveInfo {
@@ -2039,13 +2071,7 @@
if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO;
}
if(self.svgaQueue.count > 0){
[self.svgaQueue removeObjectAtIndex:0];
}
if(self.svgaQueue.count > 0 && self.isLargeGiftAnimating == NO){
[self createGiftSvgaAnimation:self.svgaQueue.firstObject];
}
} else if (player == self.luckyGiftEffectView) {
self.luckyGiftEffectView.hidden = YES;
@@ -2139,13 +2165,7 @@
if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO;
}
if(self.svgaQueue.count > 0){
[self.svgaQueue removeObjectAtIndex:0];
}
if(self.svgaQueue.count > 0 && self.isLargeGiftAnimating == NO){
[self createGiftSvgaAnimation:self.svgaQueue.firstObject];
}
} else if(container == self.luckyVapGiftEffectView) {
[self.luckyVapGiftEffectView removeFromSuperview];
@@ -2172,13 +2192,7 @@
if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO;
}
if(self.svgaQueue.count > 0){
[self.svgaQueue removeObjectAtIndex:0];
}
if(self.svgaQueue.count > 0 && self.isLargeGiftAnimating == NO){
[self createGiftSvgaAnimation:self.svgaQueue.firstObject];
}
} else if(container == self.luckyVapGiftEffectView) {
[self.luckyVapGiftEffectView removeFromSuperview];
self.luckyVapGiftEffectView = nil;