Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit db92d48

Browse files
committed
fix: play with range
1 parent 3194420 commit db92d48

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

Diff for: SVGAPlayer.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Pod::Spec.new do |s|
33
s.name = "SVGAPlayer"
4-
s.version = "2.5.5"
4+
s.version = "2.5.6"
55
s.summary = "SVGAPlayer 是一个高性能的动画播放器"
66
s.description = <<-DESC
77
SVGA 是一种全新的动画格式,由 YY UED 团队主导开发;

Diff for: SVGAPlayer/ViewController.m

+4-3
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ - (IBAction)onChange:(id)sender {
6767
NSParagraphStyleAttributeName: para,
6868
}];
6969
[self.aPlayer setAttributedText:str forKey:@"banner"];
70-
71-
// self.aPlayer.mianRunLoopMode = NSDefaultRunLoopMode;
70+
7271
[self.aPlayer startAnimation];
72+
73+
// [self.aPlayer startAnimationWithRange:NSMakeRange(10, 25) reverse:YES];
7374
}
7475
} failureBlock:nil];
75-
76+
//
7677
// [parser parseWithURL:[NSURL URLWithString:@"https://github.com/svga/SVGA-Samples/raw/master_aep/BitmapColorArea1.svga"] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
7778
// if (videoItem != nil) {
7879
// self.aPlayer.videoItem = videoItem;

Diff for: Source/SVGAPlayer.m

+17-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ - (void)startAnimation {
8989
}
9090

9191
- (void)startAnimationWithRange:(NSRange)range reverse:(BOOL)reverse {
92+
if (self.videoItem == nil) {
93+
NSLog(@"videoItem could not be nil!");
94+
return;
95+
} else if (self.drawLayer == nil) {
96+
self.videoItem = _videoItem;
97+
}
98+
[self stopAnimation:NO];
99+
self.loopCount = 0;
100+
if (self.videoItem.FPS == 0) {
101+
NSLog(@"videoItem FPS could not be 0!");
102+
return;
103+
}
104+
92105
self.currentRange = range;
93106
self.reversing = reverse;
94107
if (reverse) {
@@ -97,7 +110,10 @@ - (void)startAnimationWithRange:(NSRange)range reverse:(BOOL)reverse {
97110
else {
98111
self.currentFrame = MAX(0, range.location);
99112
}
100-
[self startAnimation];
113+
self.forwardAnimating = !self.reversing;
114+
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(next)];
115+
self.displayLink.frameInterval = 60 / self.videoItem.FPS;
116+
[self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:self.mainRunLoopMode];
101117
}
102118

103119
- (void)pauseAnimation {

0 commit comments

Comments
 (0)