引入QGVAPlayer,礼物增加VAP字段
This commit is contained in:
2
Podfile
2
Podfile
@@ -58,6 +58,8 @@ target 'xplan-ios' do
|
||||
pod 'UMDevice'
|
||||
#头饰显示
|
||||
pod 'YYWebImage', '~> 1.0.5'
|
||||
#vap礼物动画
|
||||
pod 'QGVAPlayer'
|
||||
#调试
|
||||
pod 'LookinServer', :configurations => ['Debug']
|
||||
|
||||
|
@@ -52,6 +52,7 @@ PODS:
|
||||
- NTESBaseComponent
|
||||
- pop (1.0.12)
|
||||
- Protobuf (3.19.1)
|
||||
- QGVAPlayer (1.0.15)
|
||||
- Qiniu (8.3.2):
|
||||
- HappyDNS (~> 0.3.17)
|
||||
- ReactiveObjC (3.1.1)
|
||||
@@ -107,6 +108,7 @@ DEPENDENCIES:
|
||||
- NIMSDK_LITE (~> 7.8.3)
|
||||
- NTESQuickPass
|
||||
- pop (~> 1.0.12)
|
||||
- QGVAPlayer
|
||||
- Qiniu
|
||||
- ReactiveObjC
|
||||
- SDCycleScrollView
|
||||
@@ -125,6 +127,7 @@ SPEC REPOS:
|
||||
- JXPagingView
|
||||
- NTESBaseComponent
|
||||
- NTESQuickPass
|
||||
- QGVAPlayer
|
||||
trunk:
|
||||
- AFNetworking
|
||||
- AgoraRtcEngine_iOS
|
||||
@@ -187,6 +190,7 @@ SPEC CHECKSUMS:
|
||||
NTESQuickPass: 781bd12ee63681389fe9b646c837fa76e3a00e6e
|
||||
pop: d582054913807fd11fd50bfe6a539d91c7e1a55a
|
||||
Protobuf: 3724efa50cb2846d7ccebc8691c574e85fd74471
|
||||
QGVAPlayer: 002673a02b4e50f9f53d0673b87168b540a300ae
|
||||
Qiniu: 61f1e2fdfb35b37f98c8f03a718faf12652f9994
|
||||
ReactiveObjC: 011caa393aa0383245f2dcf9bf02e86b80b36040
|
||||
SDCycleScrollView: a0d74c3384caa72bdfc81470bdbc8c14b3e1fbcf
|
||||
@@ -203,6 +207,6 @@ SPEC CHECKSUMS:
|
||||
YYText: 5c461d709e24d55a182d1441c41dc639a18a4849
|
||||
YYWebImage: 5f7f36aee2ae293f016d418c7d6ba05c4863e928
|
||||
|
||||
PODFILE CHECKSUM: 8120dbc8eb506e124ccb97e8ce2ecf2420ac8b5f
|
||||
PODFILE CHECKSUM: 1a683727ef25bd79085c9712a04f56f64ed29993
|
||||
|
||||
COCOAPODS: 1.11.2
|
||||
|
@@ -113,6 +113,8 @@
|
||||
9B0086C627BA392B0032BD2B /* AnchorStageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0086C527BA392B0032BD2B /* AnchorStageView.m */; };
|
||||
9B0086CA27BA4F570032BD2B /* AnchorMicroView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0086C927BA4F570032BD2B /* AnchorMicroView.m */; };
|
||||
9B060B5827BCAEE20001B767 /* AnchorGiftValueView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B060B5727BCAEE20001B767 /* AnchorGiftValueView.m */; };
|
||||
9B0997A127F19D8A00EB8F14 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 9B0997A027F19D8900EB8F14 /* README.md */; };
|
||||
9B0997A327F19DE500EB8F14 /* QGHWDShaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 9B0997A227F19DE500EB8F14 /* QGHWDShaders.metal */; };
|
||||
9B0E1C5926E77022005D4442 /* BaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */; };
|
||||
9B17F71827BD150600440843 /* SVGAParserManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B17F71727BD150600440843 /* SVGAParserManager.m */; };
|
||||
9B208A362779B50100F9E54A /* GiftNobleInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B208A352779B50100F9E54A /* GiftNobleInfoModel.m */; };
|
||||
@@ -179,6 +181,7 @@
|
||||
9BC5C8F9277B02EA007C8719 /* Api+NobleCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BC5C8F8277B02EA007C8719 /* Api+NobleCenter.m */; };
|
||||
9BC5C91C277C8A7B007C8719 /* XPReleaseRadioViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BC5C91B277C8A7B007C8719 /* XPReleaseRadioViewController.m */; };
|
||||
9BC5C91F277C902B007C8719 /* XPReleaseRadioView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BC5C91E277C902B007C8719 /* XPReleaseRadioView.m */; };
|
||||
9BC9DAEF27E33B3F009EE409 /* XPRoomGiftAnimationParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BC9DAEE27E33B3F009EE409 /* XPRoomGiftAnimationParser.m */; };
|
||||
9BCD02C72796C02800F396AA /* MicroNobleWaveView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BCD02C62796C02800F396AA /* MicroNobleWaveView.m */; };
|
||||
9BCE6144277D657600CC0358 /* XPReleaseRadioTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BCE6143277D657600CC0358 /* XPReleaseRadioTableViewCell.m */; };
|
||||
9BCE6147277D665600CC0358 /* XPReleaseRadioCellModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BCE6146277D665600CC0358 /* XPReleaseRadioCellModel.m */; };
|
||||
@@ -758,6 +761,8 @@
|
||||
9B0086C927BA4F570032BD2B /* AnchorMicroView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AnchorMicroView.m; sourceTree = "<group>"; };
|
||||
9B060B5627BCAEE20001B767 /* AnchorGiftValueView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AnchorGiftValueView.h; sourceTree = "<group>"; };
|
||||
9B060B5727BCAEE20001B767 /* AnchorGiftValueView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AnchorGiftValueView.m; sourceTree = "<group>"; };
|
||||
9B0997A027F19D8900EB8F14 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||
9B0997A227F19DE500EB8F14 /* QGHWDShaders.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; name = QGHWDShaders.metal; path = Pods/QGVAPlayer/iOS/QGVAPlayer/QGVAPlayer/Shaders/QGHWDShaders.metal; sourceTree = SOURCE_ROOT; };
|
||||
9B0E1C5726E77022005D4442 /* BaseNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseNavigationController.h; sourceTree = "<group>"; };
|
||||
9B0E1C5826E77022005D4442 /* BaseNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseNavigationController.m; sourceTree = "<group>"; };
|
||||
9B17F71627BD150600440843 /* SVGAParserManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAParserManager.h; sourceTree = "<group>"; };
|
||||
@@ -892,6 +897,8 @@
|
||||
9BC5C91B277C8A7B007C8719 /* XPReleaseRadioViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPReleaseRadioViewController.m; sourceTree = "<group>"; };
|
||||
9BC5C91D277C902B007C8719 /* XPReleaseRadioView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPReleaseRadioView.h; sourceTree = "<group>"; };
|
||||
9BC5C91E277C902B007C8719 /* XPReleaseRadioView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPReleaseRadioView.m; sourceTree = "<group>"; };
|
||||
9BC9DAED27E33B3F009EE409 /* XPRoomGiftAnimationParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomGiftAnimationParser.h; sourceTree = "<group>"; };
|
||||
9BC9DAEE27E33B3F009EE409 /* XPRoomGiftAnimationParser.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomGiftAnimationParser.m; sourceTree = "<group>"; };
|
||||
9BCD02C52796C02800F396AA /* MicroNobleWaveView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MicroNobleWaveView.h; sourceTree = "<group>"; };
|
||||
9BCD02C62796C02800F396AA /* MicroNobleWaveView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MicroNobleWaveView.m; sourceTree = "<group>"; };
|
||||
9BCE6142277D657600CC0358 /* XPReleaseRadioTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPReleaseRadioTableViewCell.h; sourceTree = "<group>"; };
|
||||
@@ -2064,6 +2071,7 @@
|
||||
189DD5A726DFA09700AB55B1 /* Tool */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9B09979F27F19D1C00EB8F14 /* QGVAPlayer */,
|
||||
9B33E3C827D85379003B0E62 /* File */,
|
||||
E80CBDE727D0C528001E1EC2 /* Timer */,
|
||||
180116F6279E8C3100F2CBC0 /* Date */,
|
||||
@@ -2307,6 +2315,15 @@
|
||||
path = Anchor;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9B09979F27F19D1C00EB8F14 /* QGVAPlayer */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9B0997A227F19DE500EB8F14 /* QGHWDShaders.metal */,
|
||||
9B0997A027F19D8900EB8F14 /* README.md */,
|
||||
);
|
||||
path = QGVAPlayer;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9B17F71527BD14FF00440843 /* SVGAParserManager */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -3070,6 +3087,8 @@
|
||||
9B6B3AAA278C2EA7005551EC /* XPRoomNobleLevelUpView.m */,
|
||||
E838D99E275E1BF60079E0B5 /* XPRoomAnimationView.h */,
|
||||
E838D99F275E1BF60079E0B5 /* XPRoomAnimationView.m */,
|
||||
9BC9DAED27E33B3F009EE409 /* XPRoomGiftAnimationParser.h */,
|
||||
9BC9DAEE27E33B3F009EE409 /* XPRoomGiftAnimationParser.m */,
|
||||
);
|
||||
path = AnimationView;
|
||||
sourceTree = "<group>";
|
||||
@@ -4574,6 +4593,7 @@
|
||||
E8937ACD276C3EDE00B2C7E1 /* svga_member_in_lv30.svga in Resources */,
|
||||
E8A1E462276220DA00B294CA /* candyTree_light.svga in Resources */,
|
||||
E8937ACF276C99C300B2C7E1 /* Launch Screen.storyboard in Resources */,
|
||||
9B0997A127F19D8A00EB8F14 /* README.md in Resources */,
|
||||
189DD53926DE255600AB55B1 /* Assets.xcassets in Resources */,
|
||||
E8DEC98C27637EA50078CB70 /* candyTree_transform.svga in Resources */,
|
||||
186A52E726FC559700D67B2C /* yw_1222_0769.jpg in Resources */,
|
||||
@@ -4838,6 +4858,7 @@
|
||||
E87E914E2796678D00A7B3F2 /* XPMineDressEmptyTableViewCell.m in Sources */,
|
||||
9B7D804D27537950003DAC0C /* MessageCell.m in Sources */,
|
||||
18F404C927609A4300A6C548 /* MessagePresenter.m in Sources */,
|
||||
9BC9DAEF27E33B3F009EE409 /* XPRoomGiftAnimationParser.m in Sources */,
|
||||
9B2A12DB2783F88800CED41B /* XPNoblePrivilegeCell.m in Sources */,
|
||||
E81366E326F0A1FC0076364C /* LoginBindPhoneViewController.m in Sources */,
|
||||
9B85B6DA279FDC5200A0A1AC /* XPUserCardSkillCollectionViewCell.m in Sources */,
|
||||
@@ -5063,6 +5084,7 @@
|
||||
9BCF586227995426008401A4 /* XPSkillCardSelectPropCell.m in Sources */,
|
||||
E8E70D8F26F2F5DB00F03460 /* XPMineMenuTableViewCell.m in Sources */,
|
||||
E8E5E1A927C3850400F457D8 /* XPHomeHotRoomCollectionViewCell.m in Sources */,
|
||||
9B0997A327F19DE500EB8F14 /* QGHWDShaders.metal in Sources */,
|
||||
187EEEE126E89BFB002833B2 /* AccountModel.m in Sources */,
|
||||
E896EFA92771AEEC00AD2CC1 /* XPMineAttentionTableViewCell.m in Sources */,
|
||||
9BBC02912786FC570007C24B /* XPMineNobleCardTableViewCell.m in Sources */,
|
||||
|
1
xplan-ios/Base/Tool/QGVAPlayer/README.md
Normal file
1
xplan-ios/Base/Tool/QGVAPlayer/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# 在此目录下引用QGHWDShaders.metal
|
@@ -23,6 +23,12 @@ typedef NS_ENUM(NSUInteger, GiftSourceType) {
|
||||
GiftSourceType_Pack = 2, // 背包礼物
|
||||
};
|
||||
|
||||
///礼物播放类型(0 无, 1 MP4、VAP播放)
|
||||
typedef NS_ENUM(NSUInteger, GiftOtherViewType) {
|
||||
GiftOtherViewTypeNormal = 0,
|
||||
GiftOtherViewTypeMp4 = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
赠送类型 1给主播直接刷礼物,2私聊送个人礼物,3房间内给坑位上的人送礼物,5.公聊大厅给人送礼物
|
||||
|
||||
@@ -79,6 +85,10 @@ typedef NS_ENUM(NSUInteger, RoomSendGiftType) {
|
||||
@property (assign, nonatomic) BOOL roomExclude;
|
||||
///是否支持发广播
|
||||
@property (nonatomic,assign) BOOL isSendMsg;
|
||||
///礼物文件类型 0 其他, 1 mp4
|
||||
@property (nonatomic, assign) GiftOtherViewType otherViewType;
|
||||
///mp4类型特效url
|
||||
@property (nonatomic, copy) NSString *viewUrl;
|
||||
|
||||
/**------------- 礼物背包 ----------------**/
|
||||
///个数
|
||||
|
@@ -64,6 +64,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic,strong)NSString *giftName;
|
||||
///动效url
|
||||
@property (copy,nonatomic) NSString *vggUrl;
|
||||
///vap动效url
|
||||
@property (nonatomic, copy) NSString *viewUrl;
|
||||
///非全麦 多人送礼时
|
||||
@property (nonatomic,strong) NSArray<GiftReceiveUserInfoModel *> *targetUsers;
|
||||
///福袋礼物需要展示的vg动画
|
||||
|
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// XPRoomGiftAnimationParser.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/3/17.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPRoomGiftAnimationParser : NSObject
|
||||
|
||||
- (void)parseWithURL:(nonnull NSString *)URL
|
||||
completionBlock:(void ( ^ _Nonnull )(NSString * _Nullable videoUrl))completionBlock
|
||||
failureBlock:(void ( ^ _Nullable)(NSError * _Nullable error))failureBlock;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,374 @@
|
||||
//
|
||||
// XPRoomGiftAnimationParser.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/3/17.
|
||||
//
|
||||
|
||||
#import "XPRoomGiftAnimationParser.h"
|
||||
#import <zlib.h>
|
||||
#import <SSZipArchive/SSZipArchive.h>
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
#import <AFNetworking.h>
|
||||
|
||||
@implementation XPRoomGiftAnimationParser
|
||||
|
||||
static NSOperationQueue *parseQueue;
|
||||
|
||||
+ (void)load {
|
||||
parseQueue = [NSOperationQueue new];
|
||||
parseQueue.maxConcurrentOperationCount = 8;
|
||||
}
|
||||
|
||||
- (void)parseWithURL:(nonnull NSString *)URL
|
||||
completionBlock:(void ( ^ _Nonnull )(NSString * _Nullable videoUrl))completionBlock
|
||||
failureBlock:(void ( ^ _Nullable)(NSError * _Nullable error))failureBlock {
|
||||
[self parseWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:URL] cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:20.0]
|
||||
completionBlock:completionBlock
|
||||
failureBlock:failureBlock];
|
||||
}
|
||||
|
||||
- (void)parseWithURLRequest:(NSURLRequest *)URLRequest completionBlock:(void (^)(NSString * _Nullable))completionBlock failureBlock:(void (^)(NSError * _Nullable))failureBlock {
|
||||
if (URLRequest.URL == nil) {
|
||||
if (failureBlock) {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
failureBlock([NSError errorWithDomain:@"vapParser" code:411 userInfo:@{NSLocalizedDescriptionKey: @"URL cannot be nil."}]);
|
||||
}];
|
||||
}
|
||||
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;
|
||||
}
|
||||
// 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]]];
|
||||
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
|
||||
if (!error) {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
completionBlock(filePath.absoluteString);
|
||||
}];
|
||||
} else {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
completionBlock(nil);
|
||||
}];
|
||||
}
|
||||
}] 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 {
|
||||
NSString *cacheDir = [self cacheDirectory:cacheKey];
|
||||
[[NSFileManager defaultManager] removeItemAtPath:cacheDir error:NULL];
|
||||
}
|
||||
|
||||
- (nonnull NSString *)cacheKey:(NSURL *)URL {
|
||||
return [self MD5String:URL.absoluteString];
|
||||
}
|
||||
|
||||
- (nullable NSString *)cacheDirectory:(NSString *)cacheKey {
|
||||
NSString *cacheDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
|
||||
return [cacheDir stringByAppendingFormat:@"/%@.mp4", cacheKey];
|
||||
}
|
||||
|
||||
- (NSString *)MD5String:(NSString *)str {
|
||||
const char *cstr = [str UTF8String];
|
||||
unsigned char result[16];
|
||||
CC_MD5(cstr, (CC_LONG)strlen(cstr), result);
|
||||
return [NSString stringWithFormat:
|
||||
@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
result[0], result[1], result[2], result[3],
|
||||
result[4], result[5], result[6], result[7],
|
||||
result[8], result[9], result[10], result[11],
|
||||
result[12], result[13], result[14], result[15]
|
||||
];
|
||||
}
|
||||
|
||||
@end
|
Reference in New Issue
Block a user