mirror of
https://github.com/svga/SVGAPlayer-iOS.git
synced 2025-10-21 07:29:14 +08:00
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "SVGAPlayer"
|
s.name = "SVGAPlayer"
|
||||||
s.version = "2.5.4"
|
s.version = "2.5.5"
|
||||||
s.summary = "SVGAPlayer 是一个高性能的动画播放器"
|
s.summary = "SVGAPlayer 是一个高性能的动画播放器"
|
||||||
s.description = <<-DESC
|
s.description = <<-DESC
|
||||||
SVGA 是一种全新的动画格式,由 YY UED 团队主导开发;
|
SVGA 是一种全新的动画格式,由 YY UED 团队主导开发;
|
||||||
|
@@ -50,6 +50,7 @@ static SVGAParser *parser;
|
|||||||
@"https://github.com/yyued/SVGA-Samples/blob/master/rose.svga?raw=true",
|
@"https://github.com/yyued/SVGA-Samples/blob/master/rose.svga?raw=true",
|
||||||
];
|
];
|
||||||
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
|
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
|
||||||
|
// parser.enabledMemoryCache = YES;
|
||||||
[parser parseWithURL:[NSURL URLWithString:items[arc4random() % items.count]]
|
[parser parseWithURL:[NSURL URLWithString:items[arc4random() % items.count]]
|
||||||
completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
|
completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
|
||||||
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
|
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
|
||||||
@@ -66,6 +67,8 @@ static SVGAParser *parser;
|
|||||||
NSParagraphStyleAttributeName: para,
|
NSParagraphStyleAttributeName: para,
|
||||||
}];
|
}];
|
||||||
[self.aPlayer setAttributedText:str forKey:@"banner"];
|
[self.aPlayer setAttributedText:str forKey:@"banner"];
|
||||||
|
|
||||||
|
// self.aPlayer.mianRunLoopMode = NSDefaultRunLoopMode;
|
||||||
[self.aPlayer startAnimation];
|
[self.aPlayer startAnimation];
|
||||||
}
|
}
|
||||||
} failureBlock:nil];
|
} failureBlock:nil];
|
||||||
|
@@ -28,6 +28,7 @@ typedef void(^SVGAPlayerDynamicDrawingBlock)(CALayer *contentLayer, NSInteger fr
|
|||||||
@property (nonatomic, assign) IBInspectable int loops;
|
@property (nonatomic, assign) IBInspectable int loops;
|
||||||
@property (nonatomic, assign) IBInspectable BOOL clearsAfterStop;
|
@property (nonatomic, assign) IBInspectable BOOL clearsAfterStop;
|
||||||
@property (nonatomic, copy) NSString *fillMode;
|
@property (nonatomic, copy) NSString *fillMode;
|
||||||
|
@property (nonatomic, copy) NSRunLoopMode mainRunLoopMode;
|
||||||
|
|
||||||
- (void)startAnimation;
|
- (void)startAnimation;
|
||||||
- (void)startAnimationWithRange:(NSRange)range reverse:(BOOL)reverse;
|
- (void)startAnimationWithRange:(NSRange)range reverse:(BOOL)reverse;
|
||||||
|
@@ -84,7 +84,7 @@
|
|||||||
}
|
}
|
||||||
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(next)];
|
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(next)];
|
||||||
self.displayLink.frameInterval = 60 / self.videoItem.FPS;
|
self.displayLink.frameInterval = 60 / self.videoItem.FPS;
|
||||||
[self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
[self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:self.mainRunLoopMode];
|
||||||
self.forwardAnimating = !self.reversing;
|
self.forwardAnimating = !self.reversing;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@
|
|||||||
}
|
}
|
||||||
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(next)];
|
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(next)];
|
||||||
self.displayLink.frameInterval = 60 / self.videoItem.FPS;
|
self.displayLink.frameInterval = 60 / self.videoItem.FPS;
|
||||||
[self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
[self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:self.mainRunLoopMode];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,4 +523,11 @@
|
|||||||
return _dynamicDrawings;
|
return _dynamicDrawings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSRunLoopMode)mainRunLoopMode {
|
||||||
|
if (!_mainRunLoopMode) {
|
||||||
|
_mainRunLoopMode = NSRunLoopCommonModes;
|
||||||
|
}
|
||||||
|
return _mainRunLoopMode;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
static NSCache *videoCache;
|
static NSCache *videoCache;
|
||||||
static NSMapTable * weakCache;
|
static NSMapTable * weakCache;
|
||||||
|
static dispatch_semaphore_t videoSemaphore;
|
||||||
|
|
||||||
+ (void)load {
|
+ (void)load {
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
@@ -40,6 +41,7 @@ static NSMapTable * weakCache;
|
|||||||
weakCache = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsStrongMemory
|
weakCache = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsStrongMemory
|
||||||
valueOptions:NSPointerFunctionsWeakMemory
|
valueOptions:NSPointerFunctionsWeakMemory
|
||||||
capacity:64];
|
capacity:64];
|
||||||
|
videoSemaphore = dispatch_semaphore_create(1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,19 +211,26 @@ static NSMapTable * weakCache;
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ (SVGAVideoEntity *)readCache:(NSString *)cacheKey {
|
+ (SVGAVideoEntity *)readCache:(NSString *)cacheKey {
|
||||||
|
dispatch_semaphore_wait(videoSemaphore, DISPATCH_TIME_FOREVER);
|
||||||
SVGAVideoEntity * object = [videoCache objectForKey:cacheKey];
|
SVGAVideoEntity * object = [videoCache objectForKey:cacheKey];
|
||||||
if (!object) {
|
if (!object) {
|
||||||
object = [weakCache objectForKey:cacheKey];
|
object = [weakCache objectForKey:cacheKey];
|
||||||
}
|
}
|
||||||
return object;
|
dispatch_semaphore_signal(videoSemaphore);
|
||||||
|
|
||||||
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)saveCache:(NSString *)cacheKey {
|
- (void)saveCache:(NSString *)cacheKey {
|
||||||
|
dispatch_semaphore_wait(videoSemaphore, DISPATCH_TIME_FOREVER);
|
||||||
[videoCache setObject:self forKey:cacheKey];
|
[videoCache setObject:self forKey:cacheKey];
|
||||||
|
dispatch_semaphore_signal(videoSemaphore);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)saveWeakCache:(NSString *)cacheKey {
|
- (void)saveWeakCache:(NSString *)cacheKey {
|
||||||
|
dispatch_semaphore_wait(videoSemaphore, DISPATCH_TIME_FOREVER);
|
||||||
[weakCache setObject:self forKey:cacheKey];
|
[weakCache setObject:self forKey:cacheKey];
|
||||||
|
dispatch_semaphore_signal(videoSemaphore);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Reference in New Issue
Block a user