forked from svga/SVGAPlayer-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSVGAAudioLayer.m
More file actions
37 lines (30 loc) · 1013 Bytes
/
SVGAAudioLayer.m
File metadata and controls
37 lines (30 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// SVGAAudioLayer.m
// SVGAPlayer
//
// Created by PonyCui on 2018/10/18.
// Copyright © 2018年 UED Center. All rights reserved.
//
#import "SVGAAudioLayer.h"
#import "SVGAAudioEntity.h"
#import "SVGAVideoEntity.h"
@interface SVGAAudioLayer ()
@property (nonatomic, readwrite) AVAudioPlayer *audioPlayer;
@property (nonatomic, readwrite) SVGAAudioEntity *audioItem;
@end
@implementation SVGAAudioLayer
- (instancetype)initWithAudioItem:(SVGAAudioEntity *)audioItem videoItem:(SVGAVideoEntity *)videoItem
{
self = [super init];
if (self) {
_audioItem = audioItem;
if (audioItem.audioKey != nil && videoItem.audiosData[audioItem.audioKey] != nil) {
_audioPlayer = [[AVAudioPlayer alloc] initWithData:videoItem.audiosData[audioItem.audioKey]
fileTypeHint:@"mp3"
error:NULL];
[_audioPlayer prepareToPlay];
}
}
return self;
}
@end