礼物动效缓存

This commit is contained in:
liyuhua
2024-05-15 17:35:51 +08:00
parent e47967a1e6
commit 1723782767
12 changed files with 379 additions and 331 deletions

View File

@@ -575,6 +575,9 @@
[self.messages removeObjectsInArray:needRemoveMsgArray];
}
for (NIMMessage *message in messages) {
if (![self isCanAddMsg:message]){
return;
}
[self addTimeMessage:message];
if (message.isDeleted) {
continue;
@@ -599,7 +602,11 @@
if (message.session.sessionType != NIMSessionTypeChatroom) {
return;
}
if (![self isCanAddMsg:message]){
return;
}
[self addTimeMessage:message];
if (![self isExistMessages:message]) {
if ([self isCanAddMsg:message]){
[self addTimeMessage:message];

View File

@@ -2053,11 +2053,11 @@
/// SVGA
- (void)playGiftEffect:(NSString *)vggUrl {
if ([self isInSudGame]) {return;}
NSString *baseFileName = @"/GiftSvga";
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:vggUrl];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:filePath]){
NSData *data=[NSData dataWithContentsOfFile:filePath options:0 error:NULL];
NSString *fileName = [[vggUrl componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
NSData *data=[NSData dataWithContentsOfFile:fullPath options:0 error:NULL];
[self.parser parseWithData:data cacheKey:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
if (videoItem != nil) {
@@ -2161,11 +2161,11 @@
/// vap
- (void)playGiftEffectWithVapUrl:(NSString *)vapUrl {
NSString *baseFileName = @"/GiftMp4";
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:vapUrl];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:filePath]){
vapUrl = filePath;
NSString *fileName = [[vapUrl componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
vapUrl = fullPath;
self.vapGiftEffectView.hidden = NO;
if (self.vapGiftEffectView.superview == nil) {
@@ -2205,11 +2205,11 @@
if ([self isInSudGame]) {return;}
NSString *baseFileName = @"/GiftSvga";
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:vggUrl.absoluteString];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:filePath]){
NSData *data=[NSData dataWithContentsOfFile:filePath options:0 error:NULL];
NSString *fileName = [[vggUrl.absoluteString componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
NSData *data=[NSData dataWithContentsOfFile:fullPath options:0 error:NULL];
[self.parser parseWithData:data cacheKey:@"" completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
if (videoItem != nil) {
self.luckyGiftEffectView.hidden = NO;
@@ -2284,11 +2284,11 @@
/// vap
- (void)playLuckyGiftEffectWithVapUrl:(NSString *)vapUrl {
NSString *baseFileName = @"/GiftMp4";
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:vapUrl];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:filePath]){
vapUrl = filePath;
NSString *fileName = [[vapUrl componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
vapUrl = fullPath;
self.luckyVapGiftEffectView.hidden = NO;
if (self.luckyVapGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.luckyVapGiftEffectView];

View File

@@ -77,8 +77,10 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)requestTwelveStarFirst:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid;
/// 请求缓存列表
/// @param complection 完成
/// @param roomUid 房间的roomuid
+ (void)requestCacheGiftList:(HttpRequestHelperCompletion)complection;
/// 请求新礼物动效缓存列表
/// @param complection 完成
+(void)requestCacheGiftDynamicEffectList:(HttpRequestHelperCompletion)complection;
@end
NS_ASSUME_NONNULL_END

View File

@@ -32,6 +32,12 @@
NSString * fang = @"gift/vgg";
[self makeRequest:fang method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, nil];
}
///
/// @param complection
+(void)requestCacheGiftDynamicEffectList:(HttpRequestHelperCompletion)complection{
NSString * fang = @"resource/effect";
[self makeRequest:fang method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, nil];
}
///
/// @param complection
+ (void)requestLuckGiftServerBagRecord:(HttpRequestHelperCompletion)complection {

View File

@@ -190,10 +190,11 @@
if(meQuence != nil){
[self enterRoomUpMicWith:meQuence];
}
}];
//
[self initGiftValue];
}];
}
///
-(void)enterRoomUpMicWith:(MicroQueueModel *)sequence{

View File

@@ -480,12 +480,12 @@
make.edges.mas_equalTo(self.forestImageView);
}];
NSString *baseFileName = @"/GiftMp4";
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:animtionName];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:filePath]){
NSString *fileName = [[animtionName componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
[view setMute:YES];
[view playHWDMP4:filePath repeatCount:1 delegate:self];
[view playHWDMP4:fullPath repeatCount:1 delegate:self];
}else{
[self.vapParser parseWithURL:filePath completionBlock:^(NSString * _Nullable videoUrl) {

View File

@@ -284,12 +284,12 @@
make.edges.equalTo(self.trialsBgImageView);
}];
}
NSString *baseFileName = @"/GiftMp4";
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:animtionName];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:filePath]){
NSString *fileName = [[animtionName componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
[self.trialsView setMute:YES];
[self.trialsView playHWDMP4:filePath repeatCount:1 delegate:self];
[self.trialsView playHWDMP4:fullPath repeatCount:1 delegate:self];
}else{
[self.vapParser parseWithURL:filePath completionBlock:^(NSString * _Nullable videoUrl) {

View File

@@ -336,38 +336,49 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
///
-(void)requestGiftList{
[self dealWithDefaultSvga];
///
NSString *time = [NSDate getNowTimeTimestamp];
NSString *curTime = [NSDate timestampSwitchTime:[time integerValue] andFormatter:@"yyyy-MM-dd"];
NSDictionary *timeDic = [[NSUserDefaults standardUserDefaults]valueForKey:@"kRequestGiftList"];
if(timeDic == nil){
NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic];
[curDic setValue:@(YES) forKey:curTime];
[[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"];
[[NSUserDefaults standardUserDefaults]synchronize];
}else{
if(timeDic[curTime]!= nil)return;
NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic];
[curDic removeAllObjects];
[curDic setValue:@(YES) forKey:curTime];
[[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"];
[[NSUserDefaults standardUserDefaults]synchronize];
}
///
// NSString *time = [NSDate getNowTimeTimestamp];
// NSString *curTime = [NSDate timestampSwitchTime:[time integerValue] andFormatter:@"yyyy-MM-dd"];
// NSDictionary *timeDic = [[NSUserDefaults standardUserDefaults]valueForKey:@"kRequestGiftList"];
// if(timeDic == nil){
// NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic];
// [curDic setValue:@(YES) forKey:curTime];
// [[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"];
// [[NSUserDefaults standardUserDefaults]synchronize];
// }else{
// if(timeDic[curTime]!= nil)return;
// NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic];
// [curDic removeAllObjects];
// [curDic setValue:@(YES) forKey:curTime];
// [[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"];
// [[NSUserDefaults standardUserDefaults]synchronize];
// }
[Api requestCacheGiftList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if(code == 200){
NSArray *giftList = [GiftInfoModel modelsWithArray:data.data];
for (GiftInfoModel *giftModel in giftList) {
if(giftModel.vggUrl.length > 0){
[self dealWithGiftListWithUrl:giftModel.vggUrl fileName:giftModel.vggUrl isSvga:YES];
NSString *url = [giftModel.vggUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet];
[self dealWithGiftListWithUrl:url isSvga:YES];
}else if(giftModel.viewUrl.length > 0){
[self dealWithGiftListWithUrl:giftModel.viewUrl fileName:giftModel.viewUrl isSvga:NO];
NSString *url = [giftModel.viewUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet];
[self dealWithGiftListWithUrl:url isSvga:NO];
}
}
}
}];
[Api requestCacheGiftDynamicEffectList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if(code == 200){
NSArray *list = data.data;
NSSet *setList = [[NSSet alloc]initWithArray:list];
for (NSString *url in setList) {
NSString *encodingUrl = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet];
[self cacheGiftDynamicEffectList:encodingUrl];
}
}
}];
}
@@ -376,22 +387,42 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
///
NSArray *elfList = @[@"https://image.hfighting.com/fenjie2.mp4",@"https://image.hfighting.com/treasure_fairy_ten.mp4",@"https://image.hfighting.com/hecheng3.mp4",@"https://image.hfighting.com/treasure_fairy_one.mp4"];
for (NSString *url in elfList) {
[self dealWithGiftListWithUrl:url fileName:url isSvga:NO];
NSString *encodingUrl = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet];
[self cacheGiftDynamicEffectList:encodingUrl];
[self dealWithGiftListWithUrl:encodingUrl isSvga:NO];
}
}
-(void)dealWithGiftListWithUrl:(NSString *)url fileName:(NSString *)fileName isSvga:(BOOL)isSvga {
NSString *baseFileName = isSvga ? @"/GiftSvga":@"/GiftMp4";
NSString *filePaths = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:fileName];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([[NSFileManager defaultManager] fileExistsAtPath:filePaths])return;
[[[NSURLSession sharedSession] downloadTaskWithURL:[NSURL URLWithString:url] completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if(!error){
[fileManager createDirectoryAtPath:[filePaths stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:nil];
NSData *data = [NSData dataWithContentsOfURL:location];
[data writeToFile:filePaths atomically:YES];
}
}] resume];
///
-(void)cacheGiftDynamicEffectList:(NSString *)url{
NSString *fileName = [[url componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
return;
}
NSFileManager *fileMgr = [[NSFileManager alloc] init];
[fileMgr createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];
[UploadFile downloadAudioWithFileName:fileName musicUrl:url mainFileName:@"GiftDynamicEffectList" completion:^(BOOL isSuccess, NSString *editAudioPath) {
if(isSuccess){
}else{
}
}];
}
-(void)dealWithGiftListWithUrl:(NSString *)url isSvga:(BOOL)isSvga {
///
NSString *baseFileName = isSvga ? @"/GiftSvga":@"/GiftMp4";
NSString *oldFilePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:oldFilePath]) {
BOOL isSuccess = [[NSFileManager defaultManager]removeItemAtPath:oldFilePath error:nil];
if(isSuccess == YES){
NSLog(@"删除成功");
}
}
}
- (void)checkInviteUserInfoSuccess:(InviteUserInfoModel *)inviteInfo {
@@ -410,36 +441,36 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
#pragma mark - app
- (void)clientStartApp {
// [self.presenter clientStartApp];
// [self.presenter clientStartApp];
}
#pragma mark -
- (void)networkReachability{
// @kWeakify(self);
// [[AFNetworkReachabilityManager sharedManager] startMonitoring];
// [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
// @kStrongify(self);
// switch (status) {
// case AFNetworkReachabilityStatusUnknown:
// self.isFirstReachability = YES;
// break;
// case AFNetworkReachabilityStatusNotReachable:
// self.isFirstReachability = YES;
// break;
// case AFNetworkReachabilityStatusReachableViaWWAN:
// case AFNetworkReachabilityStatusReachableViaWiFi:
// {
// if (self.isFirstReachability) {
// [[NSNotificationCenter defaultCenter] postNotificationName:kNetworkReachabilityKey object:nil userInfo:nil];
// [self.presenter autoLogin];
// [[ClientConfig shareConfig] clientInit];
// }
// self.isFirstReachability = YES;
// }
// break;
// default:
// break;
// }
// }];
// @kWeakify(self);
// [[AFNetworkReachabilityManager sharedManager] startMonitoring];
// [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
// @kStrongify(self);
// switch (status) {
// case AFNetworkReachabilityStatusUnknown:
// self.isFirstReachability = YES;
// break;
// case AFNetworkReachabilityStatusNotReachable:
// self.isFirstReachability = YES;
// break;
// case AFNetworkReachabilityStatusReachableViaWWAN:
// case AFNetworkReachabilityStatusReachableViaWiFi:
// {
// if (self.isFirstReachability) {
// [[NSNotificationCenter defaultCenter] postNotificationName:kNetworkReachabilityKey object:nil userInfo:nil];
// [self.presenter autoLogin];
// [[ClientConfig shareConfig] clientInit];
// }
// self.isFirstReachability = YES;
// }
// break;
// default:
// break;
// }
// }];
}
#pragma mark - BaseMvpProtocol
@@ -815,7 +846,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
BOOL isNotFirstLogin = [[NSUserDefaults standardUserDefaults] boolForKey:key];
if (!isNotFirstLogin) {
///
// [self.presenter getNewUserGreetInfo];
// [self.presenter getNewUserGreetInfo];
}
}

View File

@@ -260,7 +260,8 @@ static UploadFile* manager;
}
+(void)downloadAudioWithFileName:(NSString *)fileName musicUrl:(NSString *)musicUrl mainFileName:(NSString *)mainFileName completion:(void (^) (BOOL isSuccess, NSString *editAudioPath))completion {
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:musicUrl]];
NSURL *url = [NSURL URLWithString:[musicUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
NSURLRequest *request = [NSURLRequest requestWithURL :url];
NSURLSessionDownloadTask *download = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {
} destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:mainFileName] stringByAppendingPathComponent:fileName];

View File

@@ -164,8 +164,8 @@
"PKIDLoginViewController2" = "Please contact customer service";
"PKIDLoginViewController3" = "LINEpekoyuyin";
"PKIDLoginViewController4" = "I understand";
"MessageLevelUpgradeModel0" = "Congratulations! Your charm level has reached Lv%@";
"MessageLevelUpgradeModel1" = "Congratulations! Your level has reached Lv%@";
"MessageLevelUpgradeModel0" = "Congratulations! Your charm level has reached %@";
"MessageLevelUpgradeModel1" = "Congratulations! Your level has reached %@";
"MessageTextModel0" = "Unknown message type";

View File

@@ -1962,8 +1962,8 @@
"PKIDLoginViewController2" = "请联繫客服处理";
"PKIDLoginViewController3" = "LINEpekoyuyin";
"PKIDLoginViewController4" = "我知道了";
"MessageLevelUpgradeModel0" = "恭喜!您的魅力等级已到达Lv%@";
"MessageLevelUpgradeModel1" = "恭喜!您的等级已到达Lv%@";
"MessageLevelUpgradeModel0" = "恭喜!您的魅力等级已到达%@";
"MessageLevelUpgradeModel1" = "恭喜!您的等级已到达%@";
"MessageTextModel0" = "未知消息类型";

View File

@@ -1957,8 +1957,8 @@
"PKIDLoginViewController2" = "請聯繫客服處理";
"PKIDLoginViewController3" = "LINEpekoyuyin";
"PKIDLoginViewController4" = "我知道了";
"MessageLevelUpgradeModel0" = "恭喜!您的魅力等級已到達Lv%@";
"MessageLevelUpgradeModel1" = "恭喜!您的等級已到達Lv%@";
"MessageLevelUpgradeModel0" = "恭喜!您的魅力等級已到達%@";
"MessageLevelUpgradeModel1" = "恭喜!您的等級已到達%@";
"MessageTextModel0" = "未知消息類型";