mirror of
https://github.com/svga/SVGAPlayer-iOS.git
synced 2025-10-21 07:29:14 +08:00
fix: fix key for svga 1.x format.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
63712E6521787950001AE014 /* heartbeat.svga in Resources */ = {isa = PBXBuildFile; fileRef = 63712E6421787950001AE014 /* heartbeat.svga */; };
|
||||
63712E6821787A45001AE014 /* SVGAAudioEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = 63712E6721787A45001AE014 /* SVGAAudioEntity.m */; };
|
||||
63E817012178809D001D2D62 /* SVGAAudioLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E817002178809D001D2D62 /* SVGAAudioLayer.m */; };
|
||||
71418C712259FAA30029C69E /* mutiMask.svga in Resources */ = {isa = PBXBuildFile; fileRef = 71418C702259FAA30029C69E /* mutiMask.svga */; };
|
||||
71418C93225E6F710029C69E /* mutiMatte.svga in Resources */ = {isa = PBXBuildFile; fileRef = 71418C92225E6F710029C69E /* mutiMatte.svga */; };
|
||||
80D4C7254846B96B9C6EED83 /* libPods-SVGAPlayer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DDA5FF396660C7C932DF9B8 /* libPods-SVGAPlayer.a */; };
|
||||
904D41F81D223DD20085A21A /* SVGABezierPath.m in Sources */ = {isa = PBXBuildFile; fileRef = 904D41F71D223DD20085A21A /* SVGABezierPath.m */; };
|
||||
9052FC631E6EB8D4007BC925 /* SVGAExporter.m in Sources */ = {isa = PBXBuildFile; fileRef = 9052FC621E6EB8D4007BC925 /* SVGAExporter.m */; };
|
||||
@@ -64,7 +64,7 @@
|
||||
63712E6721787A45001AE014 /* SVGAAudioEntity.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SVGAAudioEntity.m; sourceTree = "<group>"; };
|
||||
63E816FF2178809D001D2D62 /* SVGAAudioLayer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAAudioLayer.h; sourceTree = "<group>"; };
|
||||
63E817002178809D001D2D62 /* SVGAAudioLayer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SVGAAudioLayer.m; sourceTree = "<group>"; };
|
||||
71418C702259FAA30029C69E /* mutiMask.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = mutiMask.svga; sourceTree = "<group>"; };
|
||||
71418C92225E6F710029C69E /* mutiMatte.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = mutiMatte.svga; sourceTree = "<group>"; };
|
||||
8AD65028FA2D122A34DC4A63 /* Pods-SVGAPlayer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SVGAPlayer.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SVGAPlayer/Pods-SVGAPlayer.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
904D41F61D223DD20085A21A /* SVGABezierPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGABezierPath.h; sourceTree = "<group>"; };
|
||||
904D41F71D223DD20085A21A /* SVGABezierPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVGABezierPath.m; sourceTree = "<group>"; };
|
||||
@@ -241,7 +241,7 @@
|
||||
90D7C9FA1F7E2AA3006E74F0 /* Samples */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
71418C702259FAA30029C69E /* mutiMask.svga */,
|
||||
71418C92225E6F710029C69E /* mutiMatte.svga */,
|
||||
63712E6421787950001AE014 /* heartbeat.svga */,
|
||||
90D7CA1A1F7FB114006E74F0 /* rose_1.5.0.svga */,
|
||||
90D7CA191F7FB114006E74F0 /* rose_2.0.0.svga */,
|
||||
@@ -350,11 +350,11 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
71418C93225E6F710029C69E /* mutiMatte.svga in Resources */,
|
||||
90A676F01D13A6DF008A69F3 /* LaunchScreen.storyboard in Resources */,
|
||||
90A676ED1D13A6DF008A69F3 /* Assets.xcassets in Resources */,
|
||||
63712E6521787950001AE014 /* heartbeat.svga in Resources */,
|
||||
90A676EB1D13A6DF008A69F3 /* Main.storyboard in Resources */,
|
||||
71418C712259FAA30029C69E /* mutiMask.svga in Resources */,
|
||||
90CB64F91EF297E800DAA382 /* SVGAPlayer React-Info.plist in Resources */,
|
||||
90D7CA1C1F7FB114006E74F0 /* rose_1.5.0.svga in Resources */,
|
||||
90D7CA1B1F7FB114006E74F0 /* rose_2.0.0.svga in Resources */,
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="4uQ-1Q-oSI">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="4uQ-1Q-oSI">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
@@ -20,7 +20,22 @@
|
||||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cmN-DO-oLC" customClass="SVGAPlayer">
|
||||
<rect key="frame" x="16" y="162" width="343" height="343"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="cmN-DO-oLC" secondAttribute="height" multiplier="1:1" id="xm5-jB-e5a"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="cmN-DO-oLC" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="HF3-PL-7Ua"/>
|
||||
<constraint firstItem="cmN-DO-oLC" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="V4O-Ov-ZmN"/>
|
||||
<constraint firstItem="cmN-DO-oLC" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="aSq-Gs-nkk"/>
|
||||
<constraint firstAttribute="trailingMargin" secondItem="cmN-DO-oLC" secondAttribute="trailing" id="vsb-Wl-Nhq"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" title="Samples" id="fYC-8C-nQt">
|
||||
<barButtonItem key="rightBarButtonItem" title="Change" id="utM-aZ-rcO">
|
||||
@@ -29,16 +44,20 @@
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</navigationItem>
|
||||
<connections>
|
||||
<outlet property="aPlayer" destination="cmN-DO-oLC" id="9nH-oR-Hmu"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-15" y="36"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="r3U-AC-YtV">
|
||||
<objects>
|
||||
<navigationController id="4uQ-1Q-oSI" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="h5y-PJ-oVu">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
|
||||
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
|
Binary file not shown.
BIN
SVGAPlayer/Samples/mutiMatte.svga
Normal file
BIN
SVGAPlayer/Samples/mutiMatte.svga
Normal file
Binary file not shown.
@@ -11,7 +11,7 @@
|
||||
|
||||
@interface ViewController ()<SVGAPlayerDelegate>
|
||||
|
||||
@property (nonatomic, strong) SVGAPlayer *aPlayer;
|
||||
@property (weak, nonatomic) IBOutlet SVGAPlayer *aPlayer;
|
||||
|
||||
@end
|
||||
|
||||
@@ -22,14 +22,15 @@ static SVGAParser *parser;
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.view.backgroundColor = [UIColor blackColor];
|
||||
[self.view addSubview:self.aPlayer];
|
||||
self.aPlayer.delegate = self;
|
||||
self.aPlayer.frame = CGRectMake(0, 0, 320, 320);
|
||||
self.aPlayer.loops = 0;
|
||||
self.aPlayer.clearsAfterStop = YES;
|
||||
parser = [[SVGAParser alloc] init];
|
||||
[parser parseWithNamed:@"mutiMask"
|
||||
[self onChange:nil];
|
||||
}
|
||||
|
||||
- (IBAction)onChange:(id)sender {
|
||||
[parser parseWithNamed:@"mutiMatte"
|
||||
inBundle:[NSBundle mainBundle] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
|
||||
if (videoItem != nil) {
|
||||
self.aPlayer.videoItem = videoItem;
|
||||
@@ -39,46 +40,4 @@ static SVGAParser *parser;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)viewWillLayoutSubviews {
|
||||
[super viewWillLayoutSubviews];
|
||||
self.aPlayer.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
|
||||
}
|
||||
|
||||
- (IBAction)onChange:(id)sender {
|
||||
NSArray *items = @[
|
||||
@"https://github.com/yyued/SVGA-Samples/blob/master/EmptyState.svga?raw=true",
|
||||
@"https://github.com/yyued/SVGA-Samples/blob/master/HamburgerArrow.svga?raw=true",
|
||||
@"https://github.com/yyued/SVGA-Samples/blob/master/PinJump.svga?raw=true",
|
||||
@"https://github.com/yyued/SVGA-Samples/blob/master/TwitterHeart.svga?raw=true",
|
||||
@"https://github.com/yyued/SVGA-Samples/blob/master/Walkthrough.svga?raw=true",
|
||||
@"https://github.com/yyued/SVGA-Samples/blob/master/angel.svga?raw=true",
|
||||
@"https://github.com/yyued/SVGA-Samples/blob/master/halloween.svga?raw=true",
|
||||
@"https://github.com/yyued/SVGA-Samples/blob/master/kingset.svga?raw=true",
|
||||
@"https://github.com/yyued/SVGA-Samples/blob/master/posche.svga?raw=true",
|
||||
@"https://github.com/yyued/SVGA-Samples/blob/master/rose.svga?raw=true",
|
||||
];
|
||||
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
|
||||
[parser parseWithURL:[NSURL URLWithString:items[arc4random() % 10]]
|
||||
completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
|
||||
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
|
||||
if (videoItem != nil) {
|
||||
self.aPlayer.videoItem = videoItem;
|
||||
[self.aPlayer startAnimation];
|
||||
}
|
||||
} failureBlock:nil];
|
||||
// [parser parseWithNamed:@"heartbeat" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
|
||||
// if (videoItem != nil) {
|
||||
// self.aPlayer.videoItem = videoItem;
|
||||
// [self.aPlayer startAnimation];
|
||||
// }
|
||||
// } failureBlock:nil];
|
||||
}
|
||||
|
||||
- (SVGAPlayer *)aPlayer {
|
||||
if (_aPlayer == nil) {
|
||||
_aPlayer = [[SVGAPlayer alloc] init];
|
||||
}
|
||||
return _aPlayer;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -151,14 +151,14 @@ static NSArray *_contentLayers;
|
||||
SVGAContentLayer *contentLayer = [sprite requestLayerWithBitmap:bitmap];
|
||||
contentLayer.imageKey = sprite.imageKey;
|
||||
tempContentLayers[sprite.imageKey] = contentLayer;
|
||||
if ([sprite.imageKey hasSuffix:@".mask"]) {
|
||||
if ([sprite.imageKey hasSuffix:@".matte"]) {
|
||||
CALayer *hostLayer = [[CALayer alloc] init];
|
||||
hostLayer.mask = contentLayer;
|
||||
[self.drawLayer addSublayer:hostLayer];
|
||||
tempHostLayers[sprite.imageKey] = hostLayer;
|
||||
} else {
|
||||
if (sprite.maskImageKey) {
|
||||
CALayer *hostLayer = tempHostLayers[sprite.maskImageKey];
|
||||
if (sprite.matteKey && sprite.matteKey.length > 0) {
|
||||
CALayer *hostLayer = tempHostLayers[sprite.matteKey];
|
||||
[hostLayer addSublayer:contentLayer];
|
||||
} else {
|
||||
[self.drawLayer addSublayer:contentLayer];
|
||||
|
@@ -15,7 +15,7 @@
|
||||
@interface SVGAVideoSpriteEntity : NSObject
|
||||
|
||||
@property (nonatomic, readonly) NSString *imageKey;
|
||||
@property (nonatomic, readonly) NSString *maskImageKey;
|
||||
@property (nonatomic, readonly) NSString *matteKey;
|
||||
@property (nonatomic, readonly) NSArray<SVGAVideoSpriteFrameEntity *> *frames;
|
||||
|
||||
- (instancetype)initWithJSONObject:(NSDictionary *)JSONObject;
|
||||
|
@@ -20,7 +20,7 @@
|
||||
if (self) {
|
||||
if ([JSONObject isKindOfClass:[NSDictionary class]]) {
|
||||
NSString *imageKey = JSONObject[@"imageKey"];
|
||||
NSString *maskImageKey = JSONObject[@"maskImageKey"];
|
||||
NSString *matteKey = JSONObject[@"matteKey"];
|
||||
NSArray<NSDictionary *> *JSONFrames = JSONObject[@"frames"];
|
||||
if ([imageKey isKindOfClass:[NSString class]] && [JSONFrames isKindOfClass:[NSArray class]]) {
|
||||
NSMutableArray<SVGAVideoSpriteFrameEntity *> *frames = [[NSMutableArray alloc] init];
|
||||
@@ -29,7 +29,7 @@
|
||||
[frames addObject:[[SVGAVideoSpriteFrameEntity alloc] initWithJSONObject:obj]];
|
||||
}
|
||||
}];
|
||||
_maskImageKey = maskImageKey;
|
||||
_matteKey = matteKey;
|
||||
_imageKey = imageKey;
|
||||
_frames = frames;
|
||||
}
|
||||
|
Reference in New Issue
Block a user