CNLiveMoviePlayerKit.h
4.54 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
//
// CNLiveMoviePlayerKit.h
// QNLiveStreamingDemo
//
// Created by iOS on 16/12/29.
// Copyright © 2016年 zhulin. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CNLiveQNLivingKit.h"
@class CNLiveMoviePlayerKit;
@protocol CNLiveMoviePlayerKitDelegate <NSObject>
@optional
/**
* 播放状态发生改变
*/
- (void)player:(CNLiveMoviePlayerKit *)player statusDidChanged:(CNLivePlayerStatus)state;
/**
* 因某些原因播放错误
*/
- (void)player:(CNLiveMoviePlayerKit *)player stoppedWithError:(NSError *)error;
/**
* 解码器错误
*/
- (void)player:(CNLiveMoviePlayerKit *)player codecError:(NSError *)error;
/**
* 点播已缓冲区域(注:直播播放无效)
* @param timeRange CMTimeRange , 表示当前缓冲区域,单位秒。
*/
- (void)player:(CNLiveMoviePlayerKit *)player loadedTimeRange:(CMTimeRange)timeRange;
@end
@interface CNLiveMoviePlayerKit : NSObject
/**
* 初始化点播播放器
* vId 点播视频Id
* authSuccessBlock 初始化成功block
* authFailureBlock 初始化失败block 回调一个errorInfo的字典
*/
- (instancetype)initVodPlayWithVId:(NSString *)vId
authSuccess:(void(^)(void))authSuccessBlock
authFailure:(void(^)(NSDictionary *errorInfo))authFailureBlock;
/**
* 初始化直播播放器
* channelId 点播视频Id
* authSuccessBlock 初始化成功block
* authFailureBlock 初始化失败block 回调一个errorInfo的字典
* resultBlock 获取主播直播状态失败,可通过 - (void)retryToGetAnchorStatusResult...方法重新获取
*/
- (instancetype)initLivePlayWithChannelId:(NSString *)channelId
authSuccess:(void(^)(void))authSuccessBlock
authFailure:(void(^)(NSDictionary *errorInfo))authFailureBlock
getAnchorStatusResult:(void(^)(BOOL result))resultBlock;
/**
* 主播直播状态
*/
@property (nonatomic, assign, readonly) CNLiveAnchorStatus anchorStatus;
/* 重新获取主播直播状态
*
* result 重新获取主播直播状态,YES:成功 NO:失败
*
*/
- (void)retryToGetAnchorStatusResult:(void(^)(BOOL result))result;
/*
* 主播直播状态改变通知
*/
FOUNDATION_EXPORT NSString *const CNLiveAnchorStatusChangedNotification NS_AVAILABLE_IOS(7_0);
/**
* 初始化普通播放器
* url 播放地址
*/
- (instancetype)initPlayerWithContentURL:(NSString *)url;
/*
* 是否开启控制台输出日志(默认YES)
*/
@property (nonatomic, assign) BOOL logPrintEnable;
/**
* 播放状态
*/
@property (nonatomic, assign, readonly) CNLivePlayerStatus status;
/**
* 播放器是否处于正在播放状态
*/
@property (nonatomic, assign, readonly) BOOL playing;
/**
* PLPlayer 的画面输出到该 UIView 对象
*/
@property (nonatomic, strong, readonly) UIView * playerView;
/**
* 是否需要静音播放,默认为NO
*/
@property (nonatomic, assign) BOOL mute;
/**
* 支持音频后台播放的开关, 默认为 YES. 当 [AVAudioSession canPlayInBackground] 为 NO 时, 该值无效。
*/
@property (nonatomic, assign) BOOL backgroundPlayEnable;
/**
* PLPlayer 的当前播放时间,仅回放状态下有效,只播放状态下将返回 CMTime(0,30)
*/
@property (nonatomic, assign, readonly) CMTime currentTime;
/**
* PLPlayer 的总播放时间,仅回放状态下有效,只播放状态下将返回 CMTime(0,30)
*/
@property (nonatomic, assign, readonly) CMTime totalDuration;
/**
* 是否开启重连,默认为 NO
*/
@property (nonatomic, assign, getter = isAutoReconnectEnable) BOOL autoReconnectEnable;
/**
* 设置画面旋转模式
*/
@property (nonatomic, assign) CNLivePLayerRotationsMode rotationMode;
@property (nonatomic, assign) id<CNLiveMoviePlayerKitDelegate> delegate;
/**
* 快速定位到指定播放时间点,该方法仅在回放时起作用,直播场景下该方法直接返回
*/
- (void)seekTo:(CMTime)time;
/**
* 开始播放
*/
- (void)play;
/**
* 当播放器处于暂停状态时调用该方法可以使播放器继续播放
*/
- (void)resume;
/**
* 当播放器处于 playing 或 caching 状态时调用该方法可以暂停播放器
*/
- (void)pause;
/**
* 停止播放器
*/
- (void)stop;
/**
* 设置音量,范围是0-1.0,默认是1.0
*/
- (void)setVolume:(float)volume;
/**
* 获取音量
*/
- (float)getVolume;
/**
* 检查当前配置是否可以播放音频
*/
+ (BOOL)audioIsPlayable;
/**
* 检查当前配置是否可以后台播放
*/
+ (BOOL)canPlayInBackground;
@end