Rename playRate to playbackRate, match the Apple API naming

This commit is contained in:
DreamPiggy 2019-11-06 01:18:49 +08:00
parent 4e157a84f9
commit 867da45caf
4 changed files with 15 additions and 15 deletions

View File

@ -35,7 +35,7 @@
/// `0.0-1.0` means the slow speed.
/// `> 1.0` means the fast speed.
/// `< 0.0` is not supported currently and stop animation. (may support reverse playback in the future)
@property (nonatomic, assign) double playRate;
@property (nonatomic, assign) double playbackRate;
/// Provide a max buffer size by bytes. This is used to adjust frame buffer count and can be useful when the decoding cost is expensive (such as Animated WebP software decoding). Default is 0.
/// `0` means automatically adjust by calculating current memory usage.

View File

@ -44,7 +44,7 @@
// Get the current frame and loop count.
self.totalLoopCount = provider.animatedImageLoopCount;
self.animatedProvider = provider;
self.playRate = 1.0;
self.playbackRate = 1.0;
#if SD_UIKIT
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
#endif
@ -228,8 +228,8 @@
NSUInteger currentFrameIndex = self.currentFrameIndex;
NSUInteger nextFrameIndex = (currentFrameIndex + 1) % totalFrameCount;
NSTimeInterval playRate = self.playRate;
if (playRate <= 0) {
NSTimeInterval playbackRate = self.playbackRate;
if (playbackRate <= 0) {
// Does not support <= 0 play rate
[self stopPlaying];
return;
@ -240,14 +240,14 @@
// Then check if timestamp is reached
self.currentTime += duration;
NSTimeInterval currentDuration = [self.animatedProvider animatedImageDurationAtIndex:currentFrameIndex];
currentDuration = currentDuration / playRate;
currentDuration = currentDuration / playbackRate;
if (self.currentTime < currentDuration) {
// Current frame timestamp not reached, return
return;
}
self.currentTime -= currentDuration;
NSTimeInterval nextDuration = [self.animatedProvider animatedImageDurationAtIndex:nextFrameIndex];
nextDuration = nextDuration / playRate;
nextDuration = nextDuration / playbackRate;
if (self.currentTime > nextDuration) {
// Do not skip frame
self.currentTime = nextDuration;

View File

@ -51,7 +51,7 @@
`> 1.0` means the fast speed.
`< 0.0` is not supported currently and stop animation. (may support reverse playback in the future)
*/
@property (nonatomic, assign) double playRate;
@property (nonatomic, assign) double playbackRate;
/**
Provide a max buffer size by bytes. This is used to adjust frame buffer count and can be useful when the decoding cost is expensive (such as Animated WebP software decoding). Default is 0.
`0` means automatically adjust by calculating current memory usage.

View File

@ -18,7 +18,7 @@
@interface SDAnimatedImageView () <CALayerDelegate> {
BOOL _initFinished; // Extra flag to mark the `commonInit` is called
double _playRate;
double _playbackRate;
}
@property (nonatomic, strong, readwrite) UIImage *currentFrame;
@ -93,7 +93,7 @@
// So the properties which rely on this order, should using lazy-evaluation or do extra check in `setImage:`.
self.shouldCustomLoopCount = NO;
self.shouldIncrementalLoad = YES;
self.playRate = 1.0;
self.playbackRate = 1.0;
#if SD_MAC
self.wantsLayer = YES;
#endif
@ -150,7 +150,7 @@
}
// Play Rate
self.player.playRate = self.playRate;
self.player.playbackRate = self.playbackRate;
// Setup handler
@weakify(self);
@ -196,18 +196,18 @@
return self.player.runLoopMode;
}
- (void)setPlayRate:(double)playRate
- (void)setPlaybackRate:(double)playbackRate
{
_playRate = playRate;
self.player.playRate = playRate;
_playbackRate = playbackRate;
self.player.playbackRate = playbackRate;
}
- (double)playRate
- (double)playbackRate
{
if (!_initFinished) {
return 1.0; // Defaults to 1.0
}
return _playRate;
return _playbackRate;
}
- (BOOL)shouldIncrementalLoad