1313#import " SVGAAudioEntity.h"
1414#import " Svga.pbobjc.h"
1515
16+ #define MP3_MAGIC_NUMBER " ID3"
17+
1618@interface SVGAVideoEntity ()
1719
1820@property (nonatomic , assign ) CGSize videoSize;
@@ -85,7 +87,7 @@ - (void)resetImagesWithJSONObject:(NSDictionary *)JSONObject {
8587 if (imageData != nil ) {
8688 UIImage *image = [[UIImage alloc ] initWithData: imageData scale: 2.0 ];
8789 if (image != nil ) {
88- [images setObject: image forKey: key];
90+ [images setObject: image forKey: [ key stringByDeletingPathExtension ] ];
8991 }
9092 }
9193 }
@@ -131,6 +133,14 @@ - (void)resetMovieWithProtoObject:(SVGAProtoMovieEntity *)protoObject {
131133 }
132134}
133135
136+ + (BOOL )isMP3Data : (NSData *)data {
137+ BOOL result = NO ;
138+ if (!strncmp ([data bytes ], MP3_MAGIC_NUMBER, strlen (MP3_MAGIC_NUMBER))) {
139+ result = YES ;
140+ }
141+ return result;
142+ }
143+
134144- (void )resetImagesWithProtoObject : (SVGAProtoMovieEntity *)protoObject {
135145 NSMutableDictionary <NSString *, UIImage *> *images = [[NSMutableDictionary alloc ] init ];
136146 NSMutableDictionary <NSString *, NSData *> *audiosData = [[NSMutableDictionary alloc ] init ];
@@ -153,9 +163,7 @@ - (void)resetImagesWithProtoObject:(SVGAProtoMovieEntity *)protoObject {
153163 }
154164 }
155165 else if ([protoImages[key] isKindOfClass: [NSData class ]]) {
156- NSData *fileTag = [protoImages[key] subdataWithRange: NSMakeRange (0 , 4 )];
157- NSString *fileTagDes = [fileTag description ];
158- if (![fileTagDes containsString: @" 89504e47" ]) {
166+ if ([SVGAVideoEntity isMP3Data: protoImages[key]]) {
159167 // mp3
160168 [audiosData setObject: protoImages[key] forKey: key];
161169 } else {
@@ -208,6 +216,7 @@ @interface SVGAVideoSpriteEntity()
208216
209217@property (nonatomic , copy ) NSString *imageKey;
210218@property (nonatomic , copy ) NSArray <SVGAVideoSpriteFrameEntity *> *frames;
219+ @property (nonatomic , copy ) NSString *matteKey;
211220
212221@end
213222
0 commit comments