Files
featherVoice/Pods/SVGAPlayer/Source/SVGAImageView.m

50 lines
1.2 KiB
Mathematica
Raw Normal View History

2025-08-08 10:49:36 +08:00
//
// SVGAImageView.m
// SVGAPlayer
//
// Created by on 2017/10/17.
// Copyright © 2017 UED Center. All rights reserved.
//
#import "SVGAImageView.h"
#import "SVGAParser.h"
static SVGAParser *sharedParser;
@implementation SVGAImageView
+ (void)load {
sharedParser = [SVGAParser new];
}
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
_autoPlay = YES;
}
return self;
}
- (void)setImageName:(NSString *)imageName {
_imageName = imageName;
if ([imageName hasPrefix:@"http://"] || [imageName hasPrefix:@"https://"]) {
[sharedParser parseWithURL:[NSURL URLWithString:imageName] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
[self setVideoItem:videoItem];
if (self.autoPlay) {
[self startAnimation];
}
} failureBlock:nil];
}
else {
[sharedParser parseWithNamed:imageName inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
[self setVideoItem:videoItem];
if (self.autoPlay) {
[self startAnimation];
}
} failureBlock:nil];
}
}
@end