VAP播放礼物动画
This commit is contained in:
@@ -11,11 +11,13 @@
|
||||
#import <SVGA.h>
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
#import <POP.h>
|
||||
#import "QGVAPConfigModel.h"
|
||||
///Tool
|
||||
#import "XPGiftStorage.h"
|
||||
#import "XPMacro.h"
|
||||
#import "ThemeColor+Room.h"
|
||||
#import "NetImageView.h"
|
||||
#import "XPRoomGiftAnimationParser.h"
|
||||
///Model
|
||||
#import "MicroQueueModel.h"
|
||||
#import "MicroStateModel.h"
|
||||
@@ -35,9 +37,9 @@
|
||||
#import "XPRoomCandyGiftView.h"
|
||||
#import "XPRoomDatingAnimationView.h"
|
||||
#import "XPRoomNobleLevelUpView.h"
|
||||
#import "QGVAPWrapView.h"
|
||||
|
||||
|
||||
@interface XPRoomAnimationView ()<SVGAPlayerDelegate,NIMBroadcastManagerDelegate, XPRoomGiftBroadcastViewDelegate>
|
||||
@interface XPRoomAnimationView ()<SVGAPlayerDelegate,NIMBroadcastManagerDelegate, XPRoomGiftBroadcastViewDelegate, VAPWrapViewDelegate>
|
||||
///展示的不同层级
|
||||
///最底层的
|
||||
@property (nonatomic,strong) XPRoomAnimationHitView * lowLevelView;
|
||||
@@ -47,8 +49,12 @@
|
||||
@property (nonatomic,strong) XPRoomAnimationHitView * highLevleView;
|
||||
///动画管理类
|
||||
@property (strong, nonatomic) SVGAParser *parser;
|
||||
///VAP动画管理
|
||||
@property (nonatomic, strong) XPRoomGiftAnimationParser *vapParser;
|
||||
///送礼物的特效
|
||||
@property (nonatomic,strong) SVGAImageView *giftEffectView;
|
||||
///VAP特效
|
||||
@property (nonatomic, strong) QGVAPWrapView *vapEffetView;
|
||||
///代理
|
||||
@property (nonatomic,weak) id<RoomHostDelegate>delegate;
|
||||
///礼物特效的队列
|
||||
@@ -779,7 +785,11 @@
|
||||
//如果是福袋礼物的话 就不用看他的价值了 只要有SVGA的话 就播放
|
||||
if (receiveInfo.displayGift.count > 0) {
|
||||
[receiveInfo.displayGift enumerateObjectsUsingBlock:^(GiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if (obj.hasVggPic && roomInfor.hasAnimationEffect) {
|
||||
if (obj.otherViewType == GiftOtherViewTypeMp4 && obj.viewUrl && obj.viewUrl.length > 0 && roomInfor.hasAnimationEffect) {
|
||||
GiftReceiveInfoModel * model = [[GiftReceiveInfoModel alloc] init];
|
||||
model.viewUrl = obj.viewUrl;
|
||||
[self.giftEffectQueue addObject:model];
|
||||
} else if (obj.hasVggPic && roomInfor.hasAnimationEffect) {
|
||||
GiftReceiveInfoModel * model = [[GiftReceiveInfoModel alloc] init];
|
||||
model.vggUrl = obj.vggUrl;
|
||||
[self.giftEffectQueue addObject:model];
|
||||
@@ -809,13 +819,17 @@
|
||||
///房间横幅
|
||||
if (giftTotal >= 520) {
|
||||
///房间横幅和 房间特效的关闭没有关系
|
||||
receiveInfo.vggUrl = giftInfo.vggUrl;
|
||||
receiveInfo.viewUrl = giftInfo.viewUrl;
|
||||
[self.giftEffectQueue addObject:receiveInfo];
|
||||
} else {
|
||||
///SVGA动画
|
||||
if (giftInfo.hasVggPic && roomInfor.hasAnimationEffect) {
|
||||
receiveInfo.vggUrl = giftInfo.vggUrl;
|
||||
[self.giftEffectQueue addObject:receiveInfo];
|
||||
}
|
||||
if (giftInfo.otherViewType == GiftOtherViewTypeMp4 && giftInfo.viewUrl.length > 0 && roomInfor.hasAnimationEffect) {
|
||||
receiveInfo.viewUrl = giftInfo.viewUrl;
|
||||
[self.giftEffectQueue addObject:receiveInfo];
|
||||
} else if (giftInfo.hasVggPic && roomInfor.hasAnimationEffect) {///SVGA动画
|
||||
receiveInfo.vggUrl = giftInfo.vggUrl;
|
||||
[self.giftEffectQueue addObject:receiveInfo];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,14 +900,18 @@
|
||||
|
||||
[springAnimation setAnimationDidStartBlock:^(POPAnimation *anim) {
|
||||
@kStrongify(self);
|
||||
if (giftInfo.hasVggPic && [self.delegate getRoomInfo].hasAnimationEffect) {
|
||||
if (giftInfo.viewUrl.length > 0 && [self.delegate getRoomInfo].hasAnimationEffect) {
|
||||
[self playGiftEffectWithVapUrl:giftInfo.viewUrl];
|
||||
} else if (giftInfo.hasVggPic && [self.delegate getRoomInfo].hasAnimationEffect) {
|
||||
[self playGiftEffect:giftInfo.vggUrl];
|
||||
}
|
||||
}];
|
||||
|
||||
[view pop_addAnimation:springAnimation forKey:@"spingOutAnimation"];
|
||||
} else {
|
||||
if (receiveInfo.vggUrl.length > 0) {///如果有特效的话就播放特效
|
||||
if (receiveInfo.viewUrl.length > 0) {//播放vap动效
|
||||
[self playGiftEffectWithVapUrl:receiveInfo.viewUrl];
|
||||
} else if (receiveInfo.vggUrl.length > 0) {///如果有特效的话就播放特效
|
||||
[self playGiftEffect:receiveInfo.vggUrl];
|
||||
}
|
||||
}
|
||||
@@ -960,6 +978,28 @@
|
||||
}];
|
||||
}
|
||||
|
||||
///播放礼物特效 vap的
|
||||
- (void)playGiftEffectWithVapUrl:(NSString *)vapUrl {
|
||||
self.vapEffetView.hidden = NO;
|
||||
if (self.vapEffetView.superview == nil) {
|
||||
[self.middleLevelView addSubview:self.vapEffetView];
|
||||
[self.vapEffetView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self.middleLevelView);
|
||||
make.width.mas_equalTo(KScreenWidth);
|
||||
make.height.mas_equalTo(KScreenHeight);
|
||||
}];
|
||||
}
|
||||
[self.vapParser parseWithURL:vapUrl completionBlock:^(NSString * _Nullable videoUrl) {
|
||||
if (videoUrl.length) {
|
||||
[self.vapEffetView setMute:YES];
|
||||
[self.vapEffetView playHWDMP4:videoUrl repeatCount:1 delegate:self];
|
||||
}
|
||||
} failureBlock:^(NSError * _Nullable error) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
///移除横幅的veiw 添加到复用池中
|
||||
- (void)removeGiftBannerView:(XPRoomGiftBannerView *)view {
|
||||
[view removeFromSuperview];
|
||||
@@ -993,6 +1033,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - VAPWrapViewDelegate
|
||||
- (BOOL)vapWrap_viewshouldStartPlayMP4:(VAPView *)container config:(QGVAPConfigModel *)config {
|
||||
CGFloat width = config.info.videoSize.width;
|
||||
CGFloat height = config.info.videoSize.height;
|
||||
if (width > height) {
|
||||
container.contentMode = UIViewContentModeScaleAspectFit;
|
||||
} else {//高大于宽
|
||||
CGFloat resizeH = KScreenWidth * height / width;//按照屏幕的宽度去缩放,获得高度
|
||||
if (resizeH > KScreenHeight) {//如果大于屏幕高度,填充
|
||||
container.contentMode = UIViewContentModeScaleAspectFill;
|
||||
} else {//小于屏幕高度,
|
||||
container.contentMode = UIViewContentModeScaleAspectFit;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)vapWrap_viewDidFinishPlayMP4:(NSInteger)totalFrameCount view:(VAPView *)container {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.vapEffetView.hidden = YES;
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (SVGAImageView *)giftEffectView {
|
||||
if (!_giftEffectView) {
|
||||
@@ -1005,6 +1068,24 @@
|
||||
return _giftEffectView;
|
||||
}
|
||||
|
||||
- (QGVAPWrapView *)vapEffetView {
|
||||
if (!_vapEffetView) {
|
||||
_vapEffetView = [[QGVAPWrapView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
||||
_vapEffetView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
|
||||
_vapEffetView.hidden = YES;
|
||||
_vapEffetView.contentMode = QGVAPWrapViewContentModeAspectFit;
|
||||
_vapEffetView.autoDestoryAfterFinish = YES;
|
||||
}
|
||||
return _vapEffetView;
|
||||
}
|
||||
|
||||
- (XPRoomGiftAnimationParser *)vapParser {
|
||||
if (!_vapParser) {
|
||||
_vapParser = [[XPRoomGiftAnimationParser alloc] init];
|
||||
}
|
||||
return _vapParser;
|
||||
}
|
||||
|
||||
- (SVGAParser *)parser {
|
||||
if (!_parser) {
|
||||
_parser = [[SVGAParser alloc]init];
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#import <SSZipArchive/SSZipArchive.h>
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
#import <AFNetworking.h>
|
||||
#import "GCDHelper.h"
|
||||
|
||||
@implementation XPRoomGiftAnimationParser
|
||||
|
||||
@@ -38,43 +39,13 @@ static NSOperationQueue *parseQueue;
|
||||
return;
|
||||
}
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:[self cacheDirectory:[self cacheKey:URLRequest.URL]]]) {
|
||||
[self parseWithCacheKey:[self cacheKey:URLRequest.URL] completionBlock:^(NSString * _Nonnull videoUrl) {
|
||||
if (completionBlock) {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
completionBlock([self cacheDirectory:[self cacheKey:URLRequest.URL]]);
|
||||
}];
|
||||
}
|
||||
} failureBlock:^(NSError * _Nonnull error) {
|
||||
[self clearCache:[self cacheKey:URLRequest.URL]];
|
||||
if (failureBlock) {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
failureBlock(error);
|
||||
}];
|
||||
}
|
||||
}];
|
||||
// return;
|
||||
if (completionBlock) {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
completionBlock([self cacheDirectory:[self cacheKey:URLRequest.URL]]);
|
||||
}];
|
||||
}
|
||||
return;
|
||||
}
|
||||
// AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
|
||||
// NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:vapUrl]];
|
||||
// NSURLSessionDownloadTask *download = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {
|
||||
// } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
|
||||
// return [NSURL fileURLWithPath:fullPath];
|
||||
// } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
|
||||
// if (!error) {
|
||||
// [self.vapEffetView setMute:YES];
|
||||
// [self.vapEffetView playHWDMP4:fullPath repeatCount:1 delegate:self];
|
||||
// }
|
||||
// }];
|
||||
// [download resume];
|
||||
|
||||
// [[AFHTTPSessionManager manager] downloadTaskWithRequest:URLRequest progress:^(NSProgress * _Nonnull downloadProgress) {
|
||||
//
|
||||
// } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
|
||||
//
|
||||
// } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
|
||||
//
|
||||
// }];
|
||||
|
||||
[[[AFHTTPSessionManager manager] downloadTaskWithRequest:URLRequest progress:^(NSProgress * _Nonnull downloadProgress) {
|
||||
} destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
|
||||
return [NSURL fileURLWithPath:[self cacheDirectory:[self cacheKey:URLRequest.URL]]];
|
||||
@@ -89,259 +60,6 @@ static NSOperationQueue *parseQueue;
|
||||
}];
|
||||
}
|
||||
}] resume];
|
||||
|
||||
// [[[NSURLSession sharedSession] dataTaskWithRequest:URLRequest completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
// if (error == nil && data != nil) {
|
||||
// [self parseWithData:data cacheKey:[self cacheKey:URLRequest.URL] completionBlock:^(NSString * _Nonnull videoUrl) {
|
||||
// if (completionBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// completionBlock(videoUrl);
|
||||
// }];
|
||||
// }
|
||||
// } failureBlock:^(NSError * _Nonnull error) {
|
||||
// [self clearCache:[self cacheKey:URLRequest.URL]];
|
||||
// if (failureBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// failureBlock(error);
|
||||
// }];
|
||||
// }
|
||||
// }];
|
||||
// }
|
||||
// else {
|
||||
// if (failureBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// failureBlock(error);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// }] resume];
|
||||
}
|
||||
|
||||
- (void)parseWithData:(nonnull NSData *)data
|
||||
cacheKey:(nonnull NSString *)cacheKey
|
||||
completionBlock:(void ( ^ _Nullable)(NSString * _Nonnull videoUrl))completionBlock
|
||||
failureBlock:(void ( ^ _Nullable)(NSError * _Nonnull error))failureBlock {
|
||||
// SVGAVideoEntity *cacheItem = [SVGAVideoEntity readCache:cacheKey];
|
||||
|
||||
// if (cacheItem != nil) {
|
||||
// if (completionBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// completionBlock(cacheItem);
|
||||
// }];
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// if (!data || data.length < 4) {
|
||||
// return;
|
||||
// }
|
||||
// if (![SVGAParser isZIPData:data]) {
|
||||
// // Maybe is SVGA 2.0.0
|
||||
// [parseQueue addOperationWithBlock:^{
|
||||
// NSData *inflateData = [self zlibInflate:data];
|
||||
// NSError *err;
|
||||
// SVGAProtoMovieEntity *protoObject = [SVGAProtoMovieEntity parseFromData:inflateData error:&err];
|
||||
// if (!err && [protoObject isKindOfClass:[SVGAProtoMovieEntity class]]) {
|
||||
// SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithProtoObject:protoObject cacheDir:@""];
|
||||
// [videoItem resetImagesWithProtoObject:protoObject];
|
||||
// [videoItem resetSpritesWithProtoObject:protoObject];
|
||||
// [videoItem resetAudiosWithProtoObject:protoObject];
|
||||
// if (self.enabledMemoryCache) {
|
||||
// [videoItem saveCache:cacheKey];
|
||||
// } else {
|
||||
// [videoItem saveWeakCache:cacheKey];
|
||||
// }
|
||||
// if (completionBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// completionBlock(videoItem);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// }];
|
||||
// return ;
|
||||
// }
|
||||
// [unzipQueue addOperationWithBlock:^{
|
||||
// if ([[NSFileManager defaultManager] fileExistsAtPath:[self cacheDirectory:cacheKey]]) {
|
||||
// [self parseWithCacheKey:cacheKey completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
|
||||
// if (completionBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// completionBlock(videoItem);
|
||||
// }];
|
||||
// }
|
||||
// } failureBlock:^(NSError * _Nonnull error) {
|
||||
// [self clearCache:cacheKey];
|
||||
// if (failureBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// failureBlock(error);
|
||||
// }];
|
||||
// }
|
||||
// }];
|
||||
// return;
|
||||
// }
|
||||
// NSString *tmpPath = [NSTemporaryDirectory() stringByAppendingFormat:@"%u.svga", arc4random()];
|
||||
// if (data != nil) {
|
||||
// [data writeToFile:tmpPath atomically:YES];
|
||||
// NSString *cacheDir = [self cacheDirectory:cacheKey];
|
||||
// if ([cacheDir isKindOfClass:[NSString class]]) {
|
||||
// [[NSFileManager defaultManager] createDirectoryAtPath:cacheDir withIntermediateDirectories:NO attributes:nil error:nil];
|
||||
// [SSZipArchive unzipFileAtPath:tmpPath toDestination:[self cacheDirectory:cacheKey] progressHandler:^(NSString * _Nonnull entry, unz_file_info zipInfo, long entryNumber, long total) {
|
||||
//
|
||||
// } completionHandler:^(NSString *path, BOOL succeeded, NSError *error) {
|
||||
// if (error != nil) {
|
||||
// if (failureBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// failureBlock(error);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if ([[NSFileManager defaultManager] fileExistsAtPath:[cacheDir stringByAppendingString:@"/movie.binary"]]) {
|
||||
// NSError *err;
|
||||
// NSData *protoData = [NSData dataWithContentsOfFile:[cacheDir stringByAppendingString:@"/movie.binary"]];
|
||||
// SVGAProtoMovieEntity *protoObject = [SVGAProtoMovieEntity parseFromData:protoData error:&err];
|
||||
// if (!err) {
|
||||
// SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithProtoObject:protoObject cacheDir:cacheDir];
|
||||
// [videoItem resetImagesWithProtoObject:protoObject];
|
||||
// [videoItem resetSpritesWithProtoObject:protoObject];
|
||||
// if (self.enabledMemoryCache) {
|
||||
// [videoItem saveCache:cacheKey];
|
||||
// } else {
|
||||
// [videoItem saveWeakCache:cacheKey];
|
||||
// }
|
||||
// if (completionBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// completionBlock(videoItem);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if (failureBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// failureBlock([NSError errorWithDomain:NSFilePathErrorKey code:-1 userInfo:nil]);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// NSError *err;
|
||||
// NSData *JSONData = [NSData dataWithContentsOfFile:[cacheDir stringByAppendingString:@"/movie.spec"]];
|
||||
// if (JSONData != nil) {
|
||||
// NSDictionary *JSONObject = [NSJSONSerialization JSONObjectWithData:JSONData options:kNilOptions error:&err];
|
||||
// if ([JSONObject isKindOfClass:[NSDictionary class]]) {
|
||||
// SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithJSONObject:JSONObject cacheDir:cacheDir];
|
||||
// [videoItem resetImagesWithJSONObject:JSONObject];
|
||||
// [videoItem resetSpritesWithJSONObject:JSONObject];
|
||||
// if (self.enabledMemoryCache) {
|
||||
// [videoItem saveCache:cacheKey];
|
||||
// } else {
|
||||
// [videoItem saveWeakCache:cacheKey];
|
||||
// }
|
||||
// if (completionBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// completionBlock(videoItem);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if (failureBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// failureBlock([NSError errorWithDomain:NSFilePathErrorKey code:-1 userInfo:nil]);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }];
|
||||
// }
|
||||
// else {
|
||||
// if (failureBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// failureBlock([NSError errorWithDomain:NSFilePathErrorKey code:-1 userInfo:nil]);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if (failureBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// failureBlock([NSError errorWithDomain:@"Data Error" code:-1 userInfo:nil]);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// }];
|
||||
}
|
||||
|
||||
- (void)parseWithCacheKey:(nonnull NSString *)cacheKey
|
||||
completionBlock:(void ( ^ _Nullable)(NSString * _Nonnull videoUrl))completionBlock
|
||||
failureBlock:(void ( ^ _Nullable)(NSError * _Nonnull error))failureBlock {
|
||||
[parseQueue addOperationWithBlock:^{
|
||||
NSString *url = [self cacheDirectory:cacheKey];
|
||||
// SVGAVideoEntity *cacheItem = [SVGAVideoEntity readCache:cacheKey];
|
||||
// if (cacheItem != nil) {
|
||||
// if (completionBlock) {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
completionBlock(url);
|
||||
}];
|
||||
// }
|
||||
// NSString *cacheDir = [self cacheDirectory:cacheKey];
|
||||
// if ([[NSFileManager defaultManager] fileExistsAtPath:[cacheDir stringByAppendingString:@"/movie.binary"]]) {
|
||||
// NSError *err;
|
||||
// NSData *protoData = [NSData dataWithContentsOfFile:[cacheDir stringByAppendingString:@"/movie.binary"]];
|
||||
// SVGAProtoMovieEntity *protoObject = [SVGAProtoMovieEntity parseFromData:protoData error:&err];
|
||||
// if (!err && [protoObject isKindOfClass:[SVGAProtoMovieEntity class]]) {
|
||||
// SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithProtoObject:protoObject cacheDir:cacheDir];
|
||||
// [videoItem resetImagesWithProtoObject:protoObject];
|
||||
// [videoItem resetSpritesWithProtoObject:protoObject];
|
||||
// [videoItem resetAudiosWithProtoObject:protoObject];
|
||||
// if (self.enabledMemoryCache) {
|
||||
// [videoItem saveCache:cacheKey];
|
||||
// } else {
|
||||
// [videoItem saveWeakCache:cacheKey];
|
||||
// }
|
||||
// if (completionBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// completionBlock(videoItem);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if (failureBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// failureBlock([NSError errorWithDomain:NSFilePathErrorKey code:-1 userInfo:nil]);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// NSError *err;
|
||||
// NSData *JSONData = [NSData dataWithContentsOfFile:[cacheDir stringByAppendingString:@"/movie.spec"]];
|
||||
// if (JSONData != nil) {
|
||||
// NSDictionary *JSONObject = [NSJSONSerialization JSONObjectWithData:JSONData options:kNilOptions error:&err];
|
||||
// if ([JSONObject isKindOfClass:[NSDictionary class]]) {
|
||||
// SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithJSONObject:JSONObject cacheDir:cacheDir];
|
||||
// [videoItem resetImagesWithJSONObject:JSONObject];
|
||||
// [videoItem resetSpritesWithJSONObject:JSONObject];
|
||||
// if (self.enabledMemoryCache) {
|
||||
// [videoItem saveCache:cacheKey];
|
||||
// } else {
|
||||
// [videoItem saveWeakCache:cacheKey];
|
||||
// }
|
||||
// if (completionBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// completionBlock(videoItem);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if (failureBlock) {
|
||||
// [[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
// failureBlock([NSError errorWithDomain:NSFilePathErrorKey code:-1 userInfo:nil]);
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)clearCache:(nonnull NSString *)cacheKey {
|
||||
|
Reference in New Issue
Block a user