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