DSPlayerView.h
6.65 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
//
// DSPlayerView.h
// DSCnliveShopSDK
//
// Created by zhaolin on 2019/6/20.
// Copyright © 2019 BIKE. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "DSPlayerTopMessageView.h"
#import "DSPlayerBottomMessageView.h"
#import "DSPlayerProgressView.h"
#import "DSPlayerFailureView.h"
UIKIT_EXTERN const float kDSPlayerAnimateTimeInterval;//动画时间
typedef NS_ENUM(NSUInteger, DSPlayerFullScreenType) { //全屏样式
DSPlayerFullScreenTypeInCurrentViewOrientation = 0, //在当前DSPlayView中旋转,用于当前播放界面为全屏样式
DSPlayerFullScreenTypeInWindowOrientation, //在window中旋转,用于小屏不是全屏显示且大屏要全屏显示
DSPlayerFullScreenTypeFullDisplayOfVideoInterface, //小屏视频展示为裁剪显示,全屏为全部展示,用于竖屏视频显示全屏属性(暂未开发)
};
NS_ASSUME_NONNULL_BEGIN
@interface DSPlayerView : UIView
#pragma mark - 播放设置
/**
初始化视频链接地址 为空为停止播放
*/
@property (nonatomic,strong,nullable,readonly) NSURL * playUrl;
/**
视频链接是否为直播
*/
@property (nonatomic,assign,readonly) BOOL isLive;
/**
初始化视频
@param playUrl 视频链接地址 为空为停止播放
@param isLive 是否为直播
*/
-(void)setPlayUrl:(NSURL * _Nullable)playUrl isLive:(BOOL)isLive;
#pragma mark - 播放属性
/**
是否循环播放(默认NO)
*/
@property (nonatomic,assign) BOOL isLoopPlay;
/// 开始播放时间
@property (nonatomic,assign) NSTimeInterval startPlayTime;
/// 获取播放时间
-(NSTimeInterval)getPlayTime;
#pragma mark - 播放状态
/**
开始/继续播放
*/
-(void)play;
/**
暂停播放
@param isRemove 是否删除kvo、通知、定时器
*/
-(void)pauseWithIsRemoveKVOsAndNotifications:(BOOL)isRemove;
/**
结束播放 如果isLoopPlay==YES,播放完成时请调用stop方法 否则该类释放不掉
*/
-(void)stop;
#pragma mark - 播放回调
/// 点击返回回调
@property (nonatomic,copy) void (^popCallBack)(void);
/**
播放器暂停回调
*/
@property (nonatomic,copy) void (^playerPausedCallBack)(DSPlayerView * playerView);
/**
播放器继续播放回调
*/
@property (nonatomic,copy) void (^playerPlayingCallBack)(DSPlayerView * playerView);
/**
播放完成回调 如果isLoopPlay==YES,播放完成时请调用stop方法 否则该类释放不掉
*/
@property (nonatomic,copy) void (^playerDidToEndCallBack)(DSPlayerView * playerView);
#pragma mark - 预览界面
/**
预览界面 (所有的控件都在这个上面)
*/
@property (nonatomic,strong) UIView * previewView;
#pragma mark - 封面图
/**
封面图(不传封面图就不显示)
*/
@property (nonatomic,strong,nullable) UIImage * coverImage;
/**
封面图url(先检测封面图,后检测封面图url,不传封面图就不显示)
*/
@property (nonatomic,copy,nullable) NSString * coverImageUrl;
/**
封面填充属性
*/
@property (nonatomic,assign) UIViewContentMode coverImageViewContentMode;
#pragma mark - 手势
/**
手势触发view
*/
@property (nonatomic,strong) UIView * gestureView;
/**
双击手势
*/
@property (nonatomic,strong) UITapGestureRecognizer * gestureViewDoubleTap;
/**
滑动手势
*/
@property (nonatomic,strong) UIPanGestureRecognizer * gestureViewPanGesture;
#pragma mark - 顶部、底部信息
/**
顶部信息view
*/
@property (nonatomic,strong) DSPlayerTopMessageView * topMessageView;
/**
竖屏顶部信息view的高度
fullScreenType == DSPlayerFullScreenTypeInCurrentViewOrientation 时默认 导航高度
fullScreenType == DSPlayerFullScreenTypeInWindowOrientation 时默认 50
fullScreenType == DSPlayerFullScreenTypeFullDisplayOfVideoInterface 时默认 导航高度
*/
@property (nonatomic,assign) CGFloat portraitTopMessageViewHeight;
/**
横屏顶部信息view的高度
fullScreenType == DSPlayerFullScreenTypeInCurrentViewOrientation 时默认 普通屏 导航高度 iPhoneX系列 20+44
fullScreenType == DSPlayerFullScreenTypeInWindowOrientation 时默认 普通屏 导航高度 iPhoneX系列 20+44
fullScreenType == DSPlayerFullScreenTypeFullDisplayOfVideoInterface 时 不存在横屏 所以此属性无效
*/
@property (nonatomic,assign) CGFloat landscapeTopMessageViewHeight;
/**
底部信息view
*/
@property (nonatomic,strong) DSPlayerBottomMessageView * bottomMessageView;
/**
竖屏底部信息view的高度
fullScreenType == DSPlayerFullScreenTypeInCurrentViewOrientation 时默认 普通屏 50 iPhoneX系列 50+底部安全区域
fullScreenType == DSPlayerFullScreenTypeInWindowOrientation 时默认 50
fullScreenType == DSPlayerFullScreenTypeFullDisplayOfVideoInterface 时默认 50
*/
@property (nonatomic,assign) CGFloat portraitBottomMessageViewHeight;
/**
横屏底部信息view的高度
fullScreenType == DSPlayerFullScreenTypeInCurrentViewOrientation 时默认 普通屏 50 iPhoneX系列 50+底部安全区域
fullScreenType == DSPlayerFullScreenTypeInWindowOrientation 时默认 普通屏 50 iPhoneX系列 50+底部安全区域
fullScreenType == DSPlayerFullScreenTypeFullDisplayOfVideoInterface 时 不存在横屏 所以此属性无效
*/
@property (nonatomic,assign) CGFloat landscapeBottomMessageViewHeight;
/// 底部进度条(当底部信息view隐藏了才会显示)
@property (nonatomic,strong) DSPlayerProgressView * bottomProgressView;
#pragma mark - 失败界面
/**
失败界面
*/
@property (nonatomic,strong) DSPlayerFailureView * failureView;
#pragma mark - BOOL值
/**
是否播放完成
*/
@property (nonatomic,assign) BOOL isPlayEnd;
/**
是否用户手动暂停
*/
@property (nonatomic,assign) BOOL isUserStop;
#pragma mark - 是否锁屏
/**
是否锁屏
*/
@property (nonatomic,assign) BOOL isLockScreen;
/**
锁屏/解锁屏回调
*/
@property (nonatomic,copy) void (^switchLockScreenCallBack)(DSPlayerView * playerView);
#pragma mark - 隐藏/显示视频上面的控件
/**
是否隐藏信息视图
*/
@property (nonatomic,assign) BOOL isAlphaMessage;
/**
隐藏/显示视频上面的控件回调
*/
@property (nonatomic,copy) void (^switchAlphaMessageStateCallBack)(DSPlayerView * playerView);
#pragma mark - 小屏/全屏
/**
全屏样式
*/
@property (nonatomic,assign) DSPlayerFullScreenType fullScreenType;
/**
是否全屏
*/
@property (nonatomic,assign,readonly) BOOL isFullScreen;
/**
退出全屏
*/
-(void)exitFullScreen;
/**
是否开启检测设备转屏 默认开启
*/
@property (nonatomic,assign) BOOL isMonitorDeviceOrientation;
/**
当前屏幕方向
*/
@property (nonatomic,assign) UIInterfaceOrientation currentOrientation;
/**
修改屏幕方向回调
*/
@property (nonatomic,copy) void (^switchInterfaceOrientationCallBack)(DSPlayerView * playerView);
@end
NS_ASSUME_NONNULL_END