PLSEditPlayer.h
5.72 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
//
// PLSEditPlayer.h
// PLShortVideoKit
//
// Created by suntongmian on 2017/7/10.
// Copyright © 2017年 Pili Engineering, Qiniu Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreVideo/CoreVideo.h>
#import "PLSTypeDefines.h"
@class PLSEditPlayer;
@protocol PLSEditPlayerDelegate <NSObject>
@optional
/**
@brief 视频数据回调, pixelBuffer 类型为 kCVPixelFormatType_32BGRA
@return 返回 kCVPixelFormatType_32BGRA 类型的 CVPixelBufferRef
@since v1.1.0
*/
- (CVPixelBufferRef __nonnull)player:(PLSEditPlayer *__nonnull)player didGetOriginPixelBuffer:(CVPixelBufferRef __nonnull)pixelBuffer __deprecated_msg("Method deprecated in v1.9.0. Use `player: didGetOriginPixelBuffer: timestamp:`");
/**
@brief 视频数据回调, pixelBuffer 类型为 kCVPixelFormatType_32BGRA
@param timestamp 视频帧的时间戳
@return 返回 kCVPixelFormatType_32BGRA 类型的 CVPixelBufferRef
@since v1.9.0
*/
- (CVPixelBufferRef __nonnull)player:(PLSEditPlayer *__nonnull)player didGetOriginPixelBuffer:(CVPixelBufferRef __nonnull)pixelBuffer timestamp:(CMTime)timestamp;
/**
@brief 当前视频的播放时刻达到了视频开头
@param item 当前视频
@param timeRange 当前视频的有效视频区域,对应 PLSEditPlayer 的属性 @property (assign, nonatomic) CMTimeRange timeRange
@since v1.9.0
*/
- (void)player:(PLSEditPlayer *__nonnull)player didReadyToPlayForItem:(AVPlayerItem *__nonnull)item timeRange:(CMTimeRange)timeRange;
/**
@brief 当前视频的播放时刻达到了视频结尾
@param item 当前视频
@param timeRange 当前视频的有效视频区域,对应 PLSEditPlayer 的属性 @property (assign, nonatomic) CMTimeRange timeRange
@since v1.9.0
*/
- (void)player:(PLSEditPlayer *__nonnull)player didReachEndForItem:(AVPlayerItem *__nonnull)item timeRange:(CMTimeRange)timeRange;
@end
@interface PLSEditPlayer : AVPlayer
/**
@brief delegate
@since v1.1.0
*/
@property (weak, nonatomic) __nullable id<PLSEditPlayerDelegate> delegate;
/**
@brief 循环播放。设置为 YE,表示单曲循环。默认为 NO
@since v1.1.0
*/
@property (assign, nonatomic) BOOL loopEnabled;
/**
@brief 播放器是否在播放状态
@since v1.1.0
*/
@property (readonly, nonatomic) BOOL isPlaying;
/**
@brief 播放器的预览视图
@since v1.1.0
*/
@property (strong, nonatomic) UIView *__nullable preview;
/**
@brief 播放器预览视图的填充方式
@since v1.1.0
*/
@property (assign, nonatomic) PLSVideoFillModeType fillMode;
/**
@brief 播放器的音量
@since v1.1.0
*/
@property (assign, nonatomic) float volume;
/**
@brief 播放器播放文件的 timeRange 范围内 [start, duration] 片段
@since v1.1.0
*/
@property (assign, nonatomic) CMTimeRange timeRange;
/**
@brief 播放器播放视频的分辨率
@since v1.5.0
*/
@property (assign, nonatomic) CGSize videoSize;
/**
@brief 初始化音频播放器
@since v1.3.0
*/
+ (PLSEditPlayer *_Nullable)audioPlayer;
/**
@brief 通过 stringPath 加载 AVPlayerItem
@since v1.1.0
*/
- (void)setItemByStringPath:(NSString *__nullable)stringPath;
/**
@brief 通过 url 加载 AVPlayerItem
@since v1.1.0
*/
- (void)setItemByUrl:(NSURL *__nullable)url;
/**
@brief 通过 asset 加载 AVPlayerItem
@since v1.1.0
*/
- (void)setItemByAsset:(AVAsset *__nullable)asset;
/**
@brief 接收 item 去播放
@since v1.1.0
*/
- (void)setItem:(AVPlayerItem *__nullable)item;
/**
@brief 播放
@since v1.1.0
*/
- (void)play;
/**
@brief 暂停
@since v1.1.0
*/
- (void)pause;
/**
* 开启水印
*
* @param waterMarkImage 水印的图片
* @param position 水印的位置
@since v1.1.0
*/
-(void)setWaterMarkWithImage:(UIImage *__nonnull)waterMarkImage position:(CGPoint)position;
/**
* 开启水印
*
* @param waterMarkImage 水印的图片
* @param position 水印的位置
* @param size 水印的大小,如果为 CGSizeZero,则使用水印图片的实际大小
@since v1.14.0
*/
-(void)setWaterMarkWithImage:(UIImage *__nonnull)waterMarkImage position:(CGPoint)position size:(CGSize)size;
/**
* 移除水印
@since v1.1.0
*/
-(void)clearWaterMark;
/**
* 添加滤镜效果
*
* @param colorImagePath 当前使用的滤镜的颜色表图的路径
@since v1.5.0
*/
- (void)addFilter:(NSString *_Nullable)colorImagePath;
/**
* 添加 MV 图层方法 1, 相当于 addMVLayerWithColor:colorURL alpha:alphaURL timeRange:kCMTimeRangeZero loopEnable:NO
*
* @param colorURL 彩色层视频的地址
* @param alphaURL 被彩色层当作透明层的视频的地址
@since v1.5.0
*/
- (void)addMVLayerWithColor:(NSURL *_Nullable)colorURL alpha:(NSURL *_Nullable)alphaURL;
/**
* 添加 MV 图层方法 2
*
* @param colorURL 彩色层视频的地址
* @param alphaURL 被彩色层当作透明层的视频的地址
* @param timeRange 选取 MV 文件的时间段, 如果选取整个 MV,直接传入 kCMTimeRangeZero 即可
* @param loopEnable 当 MV 时长(timeRange.duration)小于视频时长时,是否循环播放 MV
@since v1.14.0
*/
- (void)addMVLayerWithColor:(NSURL *)colorURL alpha:(NSURL *)alphaURL timeRange:(CMTimeRange)timeRange loopEnable:(BOOL)loopEnable;
/**
@brief 旋转视频的方向,能将竖屏视频旋转为横屏视频,横屏视频旋转为竖屏视频
*
* return PLSPreviewOrientation 当前视频的方向
@since v1.7.0
*/
- (PLSPreviewOrientation)rotateVideoLayer;
/**
@brief 重置视频的旋转方向,视频的方向被置为视频的原始方向
@since v1.7.0
*/
- (void)resetVideoLayerOrientation;
@end