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

Commit

Permalink
fix: play with range
Browse files Browse the repository at this point in the history
  • Loading branch information
yangqingren committed Nov 9, 2020
1 parent 3194420 commit db92d48
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion SVGAPlayer.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = "SVGAPlayer"
s.version = "2.5.5"
s.version = "2.5.6"
s.summary = "SVGAPlayer 是一个高性能的动画播放器"
s.description = <<-DESC
SVGA 是一种全新的动画格式,由 YY UED 团队主导开发;
Expand Down
7 changes: 4 additions & 3 deletions SVGAPlayer/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ - (IBAction)onChange:(id)sender {
NSParagraphStyleAttributeName: para,
}];
[self.aPlayer setAttributedText:str forKey:@"banner"];

// self.aPlayer.mianRunLoopMode = NSDefaultRunLoopMode;

[self.aPlayer startAnimation];

// [self.aPlayer startAnimationWithRange:NSMakeRange(10, 25) reverse:YES];
}
} failureBlock:nil];

//
// [parser parseWithURL:[NSURL URLWithString:@"https://github.com/svga/SVGA-Samples/raw/master_aep/BitmapColorArea1.svga"] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
// if (videoItem != nil) {
// self.aPlayer.videoItem = videoItem;
Expand Down
18 changes: 17 additions & 1 deletion Source/SVGAPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ - (void)startAnimation {
}

- (void)startAnimationWithRange:(NSRange)range reverse:(BOOL)reverse {
if (self.videoItem == nil) {
NSLog(@"videoItem could not be nil!");
return;
} else if (self.drawLayer == nil) {
self.videoItem = _videoItem;
}
[self stopAnimation:NO];
self.loopCount = 0;
if (self.videoItem.FPS == 0) {
NSLog(@"videoItem FPS could not be 0!");
return;
}

self.currentRange = range;
self.reversing = reverse;
if (reverse) {
Expand All @@ -97,7 +110,10 @@ - (void)startAnimationWithRange:(NSRange)range reverse:(BOOL)reverse {
else {
self.currentFrame = MAX(0, range.location);
}
[self startAnimation];
self.forwardAnimating = !self.reversing;
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(next)];
self.displayLink.frameInterval = 60 / self.videoItem.FPS;
[self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:self.mainRunLoopMode];
}

- (void)pauseAnimation {
Expand Down

0 comments on commit db92d48

Please sign in to comment.