Commit 2310ca84c522273c38725f4f66efe812a712e89c
1 parent
b43edad0
no message
Showing
13 changed files
with
292 additions
and
182 deletions
CNLivePlayer.pdf deleted
100644 → 0
No preview for this file type
CNLivePlayerSDKTest/CNLivePlayerSDK.framework/CNLivePlayerSDK
No preview for this file type
CNLivePlayerSDKTest/CNLivePlayerSDK.framework/Headers/CNLiveBarrageAnimationView.h
CNLivePlayerSDKTest/CNLivePlayerSDK.framework/Headers/CNLiveGPUStreamerKit.h
| ... | ... | @@ -13,11 +13,106 @@ |
| 13 | 13 | |
| 14 | 14 | @interface CNLiveGPUStreamerKit : NSObject |
| 15 | 15 | |
| 16 | -#pragma mark - 普通直播(可自行设置推流地址) | |
| 16 | +/** | |
| 17 | +@abstract 获取SDK版本号 | |
| 18 | +*/ | |
| 19 | ++ (NSString *)getVersion; | |
| 20 | + | |
| 21 | +#pragma mark - 使用视讯云平台 | |
| 22 | + | |
| 23 | +/** | |
| 24 | + @abstract 初始化 | |
| 25 | + @warning 实例化的对象必须赋值给一个全局变量 | |
| 26 | + @param appId 应用ID | |
| 27 | + @param appKey 注册后的应用key | |
| 28 | + @param activityId 活动ID,确保SP下的唯一性 | |
| 29 | + @param channelId 主播ID | |
| 30 | + @param isHorizontalScreen 屏幕方向,0:垂直即竖屏 /1:水平即横屏 ,默认为1 | |
| 31 | + @param success 用于返回初始化状态(成功) | |
| 32 | + @param failure 用于返回初始化状态(失败) | |
| 33 | + @warning 必传参数 | |
| 34 | + */ | |
| 35 | +-(instancetype)initWithDefaultConfigWithAppId:(NSString *)appId | |
| 36 | + appKey:(NSString *)appKey | |
| 37 | + activityId:(NSString *)activityId | |
| 38 | + channelId:(NSString *)channelId | |
| 39 | + isHorizontalScreen:(NSString *)isHorizontalScreen; | |
| 40 | + | |
| 41 | +/** | |
| 42 | + @abstract 获取推流地址 | |
| 43 | + @warning 请传入所需参数后调用 (若返回失败请重新调用此方法获取推流地址) | |
| 44 | + */ | |
| 45 | +- (void)getStreamerURLWithSuccess:(void (^)(void))success | |
| 46 | + failure :(void (^)(NSError *error))failure; | |
| 47 | + | |
| 48 | +/** | |
| 49 | + @abstract 活动名称(非必传) | |
| 50 | + */ | |
| 51 | +@property (nonatomic, strong) NSString *activityName; | |
| 52 | + | |
| 53 | +/** | |
| 54 | + @abstract 活动状态,0:未开始 /1:已开始 /3:已结束 /4 已下线,默认为0(非必传) | |
| 55 | + */ | |
| 56 | +@property (nonatomic, strong) NSString *activityStatus; | |
| 57 | + | |
| 58 | +/** | |
| 59 | + @abstract 开始时间,格式yyyyMMddHHmmss(非必传) | |
| 60 | + */ | |
| 61 | +@property (nonatomic, strong) NSString *startTime; | |
| 62 | + | |
| 63 | +/** | |
| 64 | + @abstract 结束时间,格式yyyyMMddHHmmss(非必传) | |
| 65 | + */ | |
| 66 | +@property (nonatomic, strong) NSString *endTime; | |
| 67 | + | |
| 68 | +/** | |
| 69 | + @abstract 活动封面(非必传) | |
| 70 | + */ | |
| 71 | +@property (nonatomic, strong) NSString *coverImgUrl; | |
| 72 | + | |
| 73 | +/** | |
| 74 | + @abstract 活动分类ID(非必传) | |
| 75 | + */ | |
| 76 | +@property (nonatomic, strong) NSString *activityCategory; | |
| 77 | + | |
| 78 | +/** | |
| 79 | + @abstract 扩展字段,参数格式为Map对象的Json字符串(主播昵称、头像、)(非必传) | |
| 80 | + */ | |
| 81 | +@property (nonatomic, strong) NSString *extensions; | |
| 82 | + | |
| 83 | +/** | |
| 84 | + @abstract 回调通知活动状态(错误,结束、心跳异常等状态),post 参数activityid、activitystatus值...(非必传) | |
| 85 | + */ | |
| 86 | +@property (nonatomic, strong) NSString *callbackAcitvityStatushttpPostUrl; | |
| 87 | + | |
| 88 | +/** | |
| 89 | + @abstract 启动推流 | |
| 90 | + @warning 鉴权成功后开启推流 | |
| 91 | + */ | |
| 92 | +- (void) startStream:(void (^)(void))success failure:(void (^)(NSError *error))failure; | |
| 93 | + | |
| 94 | +/** | |
| 95 | + @abstract 推流过程中异常通知 | |
| 96 | + */ | |
| 97 | +FOUNDATION_EXPORT NSString *const CNLiveStreamAbnormalNotification NS_AVAILABLE_IOS(7_0); | |
| 98 | + | |
| 99 | +/** | |
| 100 | + @abstract 结束推流成功 | |
| 101 | + */ | |
| 102 | +FOUNDATION_EXPORT NSString *const CNLiveStreamStopSuccessNotification NS_AVAILABLE_IOS(7_0); | |
| 103 | + | |
| 104 | +/** | |
| 105 | + @abstract 结束推流失败 | |
| 106 | + */ | |
| 107 | +FOUNDATION_EXPORT NSString *const CNLiveStreamStopFailedNotification NS_AVAILABLE_IOS(7_0); | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | +#pragma mark - 普通推流 | |
| 17 | 112 | |
| 18 | 113 | /** |
| 19 | 114 | @abstract 初始化 |
| 20 | - @warning 要用全局变量进行初始化 | |
| 115 | + @warning 实例化的对象必须赋值给一个全局变量 | |
| 21 | 116 | */ |
| 22 | 117 | -(instancetype)initWithDefaultConfig; |
| 23 | 118 | |
| ... | ... | @@ -28,6 +123,16 @@ |
| 28 | 123 | @property (nonatomic, assign) CNLiveVideoDimension videoDimension; |
| 29 | 124 | |
| 30 | 125 | /** |
| 126 | + @abstract 用户定义的视频分辨率 | |
| 127 | + @discussion 当videoDimension 设置为 CNLiveVideoDimension_UserDefine_* 时有效 | |
| 128 | + @discussion 内部始终将较大的值作为宽度 (若需要竖屏,请设置 videoOrientation) | |
| 129 | + @discussion 宽高都会向上取整为4的整数倍 | |
| 130 | + @discussion 宽度有效范围[160, 1280] | |
| 131 | + @discussion 高度有效范围[ 90, 720] | |
| 132 | + */ | |
| 133 | +@property (nonatomic, assign) CGSize videoDimensionUserDefine; | |
| 134 | + | |
| 135 | +/** | |
| 31 | 136 | @abstract 视频编码器 |
| 32 | 137 | @discussion video codec used for encode |
| 33 | 138 | */ |
| ... | ... | @@ -53,7 +158,7 @@ |
| 53 | 158 | @property (nonatomic, assign) int videoMinBitrate; |
| 54 | 159 | |
| 55 | 160 | /** |
| 56 | - @abstract 最大关键帧间隔(单位:秒, 默认:2) | |
| 161 | + @abstract 最大关键帧间隔(单位:秒, 默认:3) | |
| 57 | 162 | @discussion 即GOP长度 画面静止时,隔n秒插入一个关键帧 |
| 58 | 163 | */ |
| 59 | 164 | @property (nonatomic, assign) int maxKeyInterval; |
| ... | ... | @@ -72,13 +177,13 @@ |
| 72 | 177 | |
| 73 | 178 | /** |
| 74 | 179 | @abstract 视频帧率 |
| 75 | - @discussion video frame per seconds 有效范围[1~30], 超出会提示参数错误 | |
| 180 | + @discussion video frame per seconds 有效范围[15~30] | |
| 76 | 181 | */ |
| 77 | 182 | @property (nonatomic, assign) int videoFPS; |
| 78 | 183 | |
| 79 | 184 | /** |
| 80 | - @abstract 启用是否开启美颜 | |
| 81 | - @discussion 默认为开启,开始预览前设置有效 | |
| 185 | + @abstract 是否开启美颜 | |
| 186 | + @discussion 默认为开启 | |
| 82 | 187 | */ |
| 83 | 188 | @property (nonatomic, assign) BOOL isOpenImageFilter; |
| 84 | 189 | |
| ... | ... | @@ -89,6 +194,12 @@ |
| 89 | 194 | @property (nonatomic, assign) AVCaptureDevicePosition cameraPosition; |
| 90 | 195 | |
| 91 | 196 | /** |
| 197 | + @abstract 切换摄像头 | |
| 198 | + @return TRUE: 成功切换摄像头,开启预览后设置有效 | |
| 199 | + */ | |
| 200 | +- (BOOL) switchCamera; | |
| 201 | + | |
| 202 | +/** | |
| 92 | 203 | @abstract 开关闪光灯 |
| 93 | 204 | @discussion 切换闪光灯的开关状态 开 <--> 关 |
| 94 | 205 | @warning 对后摄像头设置有效 |
| ... | ... | @@ -97,7 +208,7 @@ |
| 97 | 208 | - (void) setTorchMode:(AVCaptureTorchMode)mode; |
| 98 | 209 | |
| 99 | 210 | /** |
| 100 | - @abstract 摄像头朝向 | |
| 211 | + @abstract 画面朝向描述的是横屏还是竖屏,需要与UI朝向一致,否则会出现画面缺失的情况,第一次设置有效 | |
| 101 | 212 | */ |
| 102 | 213 | - (void) setVideoOrientationBy:(UIInterfaceOrientation)uiOrien; |
| 103 | 214 | |
| ... | ... | @@ -119,15 +230,11 @@ |
| 119 | 230 | /** |
| 120 | 231 | @abstract 启动推流 |
| 121 | 232 | @param hostURL rtmp 服务器地址 “rtmp://xxx.xxx.xxx.xxx/appname/streamKey" |
| 122 | - @discussion 设置完成推流参数之后,将媒体流推送到 publishURL 对应的地址 | |
| 123 | - @discussion 推流参数主要是视频编码器,音视频码率的设置 | |
| 124 | - @warning 不鉴权直接传入推流地址 | |
| 125 | 233 | */ |
| 126 | 234 | - (void) startStream:(NSURL *)hostURL; |
| 127 | 235 | |
| 128 | 236 | /** |
| 129 | 237 | @abstract 停止推流 |
| 130 | - @discussion 断开网络连接,停止视频编码 | |
| 131 | 238 | */ |
| 132 | 239 | - (void) stopStream; |
| 133 | 240 | |
| ... | ... | @@ -157,93 +264,4 @@ FOUNDATION_EXPORT NSString *const CNLiveStreamStateDidChangeNotification NS_AVAI |
| 157 | 264 | */ |
| 158 | 265 | @property (nonatomic, assign) CNLiveStreamErrorCode streamErrorCode; |
| 159 | 266 | |
| 160 | -#pragma mark - 视讯云相关部分 | |
| 161 | - | |
| 162 | -/** | |
| 163 | - @abstract 初始化 | |
| 164 | - @warning 要用全局变量进行初始化 | |
| 165 | - @param appId 应用ID | |
| 166 | - @param appKey 注册后的应用key | |
| 167 | - @param activityId 活动ID,确保SP下的唯一性 | |
| 168 | - @param channelId 主播ID | |
| 169 | - @param isHorizontalScreen 屏幕方向,0:垂直即竖屏 /1:水平即横屏 ,默认为1 | |
| 170 | - @param success 用于返回初始化状态(成功) | |
| 171 | - @param failure 用于返回初始化状态(失败) | |
| 172 | - @warning 必传参数 | |
| 173 | - */ | |
| 174 | --(instancetype)initWithDefaultConfigWithAppId:(NSString *)appId | |
| 175 | - appKey:(NSString *)appKey | |
| 176 | - activityId:(NSString *)activityId | |
| 177 | - channelId:(NSString *)channelId | |
| 178 | - isHorizontalScreen:(NSString *)isHorizontalScreen; | |
| 179 | - | |
| 180 | -/** | |
| 181 | - @abstract 获取推流地址 | |
| 182 | - @warning 请传入所需参数后调用 (若返回失败请重新调用此方法获取推流地址) | |
| 183 | - */ | |
| 184 | -- (void)getStreamerURLWithSuccess:(void (^)(void))success | |
| 185 | - failure :(void (^)(NSError *error))failure; | |
| 186 | - | |
| 187 | -/** | |
| 188 | - @abstract 活动名称(非必传) | |
| 189 | - */ | |
| 190 | -@property (nonatomic, strong) NSString *activityName; | |
| 191 | - | |
| 192 | -/** | |
| 193 | - @abstract 活动状态,0:未开始 /1:已开始 /3:已结束 /4 已下线,默认为0(非必传) | |
| 194 | - */ | |
| 195 | -@property (nonatomic, strong) NSString *activityStatus; | |
| 196 | - | |
| 197 | -/** | |
| 198 | - @abstract 开始时间,格式yyyyMMddHHmmss(非必传) | |
| 199 | - */ | |
| 200 | -@property (nonatomic, strong) NSString *startTime; | |
| 201 | - | |
| 202 | -/** | |
| 203 | - @abstract 结束时间,格式yyyyMMddHHmmss(非必传) | |
| 204 | - */ | |
| 205 | -@property (nonatomic, strong) NSString *endTime; | |
| 206 | - | |
| 207 | -/** | |
| 208 | - @abstract 活动封面(非必传) | |
| 209 | - */ | |
| 210 | -@property (nonatomic, strong) NSString *coverImgUrl; | |
| 211 | - | |
| 212 | -/** | |
| 213 | - @abstract 活动分类ID(非必传) | |
| 214 | - */ | |
| 215 | -@property (nonatomic, strong) NSString *activityCategory; | |
| 216 | - | |
| 217 | -/** | |
| 218 | - @abstract 扩展字段,参数格式为Map对象的Json字符串(主播昵称、头像、)(非必传) | |
| 219 | - */ | |
| 220 | -@property (nonatomic, strong) NSString *extensions; | |
| 221 | - | |
| 222 | -/** | |
| 223 | - @abstract 回调通知活动状态(错误,结束、心跳异常等状态),post 参数activityid、activitystatus值...(非必传) | |
| 224 | - */ | |
| 225 | -@property (nonatomic, strong) NSString *callbackAcitvityStatushttpPostUrl; | |
| 226 | - | |
| 227 | -/** | |
| 228 | - @abstract 启动推流 | |
| 229 | - @discussion 设置完成推流参数之后,将媒体流推送到 publishURL 对应的地址 | |
| 230 | - @warning 鉴权成功后开启推流 | |
| 231 | - */ | |
| 232 | -- (void) startStream:(void (^)(void))success failure:(void (^)(NSError *error))failure; | |
| 233 | - | |
| 234 | -/** | |
| 235 | - @abstract 推流过程中异常通知 | |
| 236 | - */ | |
| 237 | -FOUNDATION_EXPORT NSString *const CNLiveStreamAbnormalNotification NS_AVAILABLE_IOS(7_0); | |
| 238 | - | |
| 239 | -/** | |
| 240 | - @abstract 结束推流成功 | |
| 241 | - */ | |
| 242 | -FOUNDATION_EXPORT NSString *const CNLiveStreamStopSuccessNotification NS_AVAILABLE_IOS(7_0); | |
| 243 | - | |
| 244 | -/** | |
| 245 | - @abstract 结束推流失败 | |
| 246 | - */ | |
| 247 | -FOUNDATION_EXPORT NSString *const CNLiveStreamStopFailedNotification NS_AVAILABLE_IOS(7_0); | |
| 248 | - | |
| 249 | 267 | @end | ... | ... |
CNLivePlayerSDKTest/CNLivePlayerSDK.framework/Headers/CNLiveMoviePlayerController.h
| ... | ... | @@ -10,35 +10,52 @@ |
| 10 | 10 | |
| 11 | 11 | @interface CNLiveMoviePlayerController : NSObject |
| 12 | 12 | |
| 13 | -#pragma mark - 视讯云内容相关方法 直接通过节目id播放 | |
| 14 | -/* 初始化点播播放器 | |
| 13 | +/* | |
| 14 | + * 获取SDK版本号 | |
| 15 | + */ | |
| 16 | ++ (NSString *)getVersion; | |
| 17 | + | |
| 18 | +#pragma mark - 使用视讯云平台 直接通过节目id播放 | |
| 19 | +/* 初始化点播播放器 初始化成功后才能对播放器进行设置(如:自动播放、是否开启硬件解码等)和调用准备播放视频方法(prepareToPlay) | |
| 20 | + * | |
| 21 | + * 当前版本只支持单实例的CNLiveMoviePlayerController对象,多实例将导致播放异常 | |
| 15 | 22 | * |
| 16 | 23 | * appId 在open.cnlive.com网站申请得到的appId |
| 17 | 24 | * appKey 在open.cnlive.com网站申请得到的app_key |
| 18 | - * vId 点播Id | |
| 25 | + * vId 点播视频Id | |
| 26 | + * authSuccess 初始化成功block | |
| 27 | + * authFailed 初始化失败block 回调一个errorInfo的字典 | |
| 19 | 28 | * |
| 20 | 29 | */ |
| 21 | 30 | - (instancetype)initVodPlayWithAppId:(NSString *)appId |
| 22 | 31 | appKey:(NSString *)appKey |
| 23 | - vId:(NSString *)vId; | |
| 32 | + vId:(NSString *)vId | |
| 33 | + authSuccess:(void(^)(void))authSuccessBlock | |
| 34 | + authFailed:(void(^)(NSDictionary *errorInfo))authFailedBlock; | |
| 24 | 35 | |
| 25 | -/* 初始化直播播放器 只有在completionBlock回调后才能对播放器进行操作 | |
| 36 | +/* 初始化直播播放器 初始化成功后才能对播放器进行设置(如:自动播放、是否开启硬件解码等)和调用准备播放视频方法(prepareToPlay) | |
| 37 | + * | |
| 38 | + * 当前版本只支持单实例的CNLiveMoviePlayerController对象,多实例将导致播放异常 | |
| 26 | 39 | * |
| 27 | 40 | * appId 在open.cnlive.com网站申请得到的appId |
| 28 | 41 | * appKey 在open.cnlive.com网站申请得到的app_key |
| 29 | - * channelId 直播Id | |
| 30 | - * completion 初始化完成 | |
| 42 | + * channelId 直播视频Id | |
| 43 | + * authSuccess 初始化成功block | |
| 44 | + * authFailed 初始化失败block 回调一个errorInfo的字典 | |
| 31 | 45 | * |
| 32 | 46 | */ |
| 33 | 47 | - (instancetype)initLivePlayWithAppId:(NSString *)appId |
| 34 | 48 | appKey:(NSString *)appKey |
| 35 | 49 | channelId:(NSString *)channelId |
| 36 | - completion:(void(^)(void))completionBlock; | |
| 50 | + authSuccess:(void(^)(void))authSuccessBlock | |
| 51 | + authFailed:(void(^)(NSDictionary *errorInfo))authFailedBlock; | |
| 37 | 52 | |
| 38 | 53 | /* 切换视角和码率 |
| 39 | 54 | * |
| 40 | - * channelId 直播Id | |
| 41 | - * rate 清晰度(1、2、3、4) | |
| 55 | + * 调用此方法会获取视频的不同视角或码率,并重新加载视频(获取视频的不同视角或码率需要一定的时间,在这段时间内,播放器不会停止播放,建议将播放器设为暂停状态(pause),并展示加载视频时的UI) | |
| 56 | + * | |
| 57 | + * channelId 直播视频Id(同一视角可不传) | |
| 58 | + * rate 清晰度(1 流畅、2 标清(默认)、3 高清、4 超清) | |
| 42 | 59 | * |
| 43 | 60 | */ |
| 44 | 61 | - (void)changeViewWithChannelId:(NSString *)channelId rate:(NSString *)rate; |
| ... | ... | @@ -46,6 +63,7 @@ |
| 46 | 63 | /* 切换视频源 |
| 47 | 64 | * |
| 48 | 65 | * 当视频不够流畅时可调用此方法 |
| 66 | + * 调用此方法会获取不同的视频源,并重新加载视频(获取其他视频源需要一定的时间,在这段时间内,播放器不会停止播放,建议将播放器设为暂停状态(pause),并展示加载视频时的UI) | |
| 49 | 67 | * |
| 50 | 68 | */ |
| 51 | 69 | - (void)retry; | ... | ... |
CNLivePlayerSDKTest/CNLivePlayerSDK.framework/Headers/CNLiveTypeDef.h
| ... | ... | @@ -100,25 +100,25 @@ typedef NS_ENUM(NSUInteger, CNLiveStreamErrorCode) { |
| 100 | 100 | CNLiveStreamErrorCode_CONNECT_FAILED, |
| 101 | 101 | /// 网络连接中断 |
| 102 | 102 | CNLiveStreamErrorCode_CONNECT_BREAK, |
| 103 | - /// rtmp 推流域名不存在 (CNLive 自定义) | |
| 103 | + /// rtmp 推流域名不存在 | |
| 104 | 104 | CNLiveStreamErrorCode_RTMP_NonExistDomain, |
| 105 | - /// rtmp 应用名不存在(CNLive 自定义) | |
| 105 | + /// rtmp 应用名不存在 | |
| 106 | 106 | CNLiveStreamErrorCode_RTMP_NonExistApplication, |
| 107 | - /// rtmp 流名已存在(CNLive 自定义) | |
| 107 | + /// rtmp 流名已存在 | |
| 108 | 108 | CNLiveStreamErrorCode_RTMP_AlreadyExistStreamName, |
| 109 | - /// rtmp 被黑名单拒绝(CNLive 自定义) | |
| 109 | + /// rtmp 被黑名单拒绝 | |
| 110 | 110 | CNLiveStreamErrorCode_RTMP_ForbiddenByBlacklist, |
| 111 | - /// rtmp 内部错误(CNLive 自定义) | |
| 111 | + /// rtmp 内部错误 | |
| 112 | 112 | CNLiveStreamErrorCode_RTMP_InternalError, |
| 113 | - /// rtmp URL 地址已过期(CNLive 自定义) | |
| 113 | + /// rtmp URL 地址已过期 | |
| 114 | 114 | CNLiveStreamErrorCode_RTMP_URLExpired, |
| 115 | - /// rtmp URL 地址签名错误(CNLive 自定义) | |
| 115 | + /// rtmp URL 地址签名错误 | |
| 116 | 116 | CNLiveStreamErrorCode_RTMP_SignatureDoesNotMatch, |
| 117 | - /// rtmp URL 中AccessKeyId非法(CNLive 自定义) | |
| 117 | + /// rtmp URL 中AccessKeyId非法 | |
| 118 | 118 | CNLiveStreamErrorCode_RTMP_InvalidAccessKeyId, |
| 119 | - /// rtmp URL 中参数错误(CNLive 自定义) | |
| 119 | + /// rtmp URL 中参数错误 | |
| 120 | 120 | CNLiveStreamErrorCode_RTMP_BadParams, |
| 121 | - /// rtmp URL 中的推流不在发布点内(CNLive 自定义) | |
| 121 | + /// rtmp URL 中的推流不在发布点内 | |
| 122 | 122 | CNLiveStreamErrorCode_RTMP_ForbiddenByRegion, |
| 123 | 123 | /// SDK 因为鉴权失败停止推流 |
| 124 | 124 | CNLiveStreamErrorCode_FRAMES_THRESHOLD, | ... | ... |
CNLivePlayerSDKTest/CNLivePlayerSDK.framework/Info.plist
No preview for this file type
CNLivePlayerSDKTest/CNLivePlayerSDKTest.xcodeproj/project.pbxproj
| ... | ... | @@ -7,6 +7,10 @@ |
| 7 | 7 | objects = { |
| 8 | 8 | |
| 9 | 9 | /* Begin PBXBuildFile section */ |
| 10 | + 3228BEAF1D9B969A002E600B /* CNLivePlayerSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3228BEAD1D9B9692002E600B /* CNLivePlayerSDK.framework */; }; | |
| 11 | + 3228BEB01D9B969A002E600B /* CNLivePlayerSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3228BEAD1D9B9692002E600B /* CNLivePlayerSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; | |
| 12 | + 32B4C85A1D9B66A400925AF0 /* CNLiveViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 32B4C8591D9B66A400925AF0 /* CNLiveViewController.m */; }; | |
| 13 | + 32B4C85D1D9B66E500925AF0 /* StreamerDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 32B4C85C1D9B66E500925AF0 /* StreamerDetailViewController.m */; }; | |
| 10 | 14 | 32E6CA2B1D5B0AF400B58EBC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6CA2A1D5B0AF400B58EBC /* main.m */; }; |
| 11 | 15 | 32E6CA2E1D5B0AF400B58EBC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6CA2D1D5B0AF400B58EBC /* AppDelegate.m */; }; |
| 12 | 16 | 32E6CA311D5B0AF400B58EBC /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6CA301D5B0AF400B58EBC /* ViewController.m */; }; |
| ... | ... | @@ -14,13 +18,9 @@ |
| 14 | 18 | 32E6CA361D5B0AF400B58EBC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 32E6CA351D5B0AF400B58EBC /* Assets.xcassets */; }; |
| 15 | 19 | 32E6CA391D5B0AF400B58EBC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32E6CA371D5B0AF400B58EBC /* LaunchScreen.storyboard */; }; |
| 16 | 20 | 32E6CA901D5B2AF700B58EBC /* BarrageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6CA831D5B2AF700B58EBC /* BarrageViewController.m */; }; |
| 17 | - 32E6CA911D5B2AF700B58EBC /* CNLiveViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6CA861D5B2AF700B58EBC /* CNLiveViewController.m */; }; | |
| 18 | 21 | 32E6CA921D5B2AF700B58EBC /* NormalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6CA881D5B2AF700B58EBC /* NormalViewController.m */; }; |
| 19 | 22 | 32E6CA931D5B2AF700B58EBC /* PlayerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6CA8A1D5B2AF700B58EBC /* PlayerViewController.m */; }; |
| 20 | - 32E6CA941D5B2AF700B58EBC /* StreamerDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6CA8D1D5B2AF700B58EBC /* StreamerDetailViewController.m */; }; | |
| 21 | 23 | 32E6CA951D5B2AF700B58EBC /* StreamerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6CA8F1D5B2AF700B58EBC /* StreamerViewController.m */; }; |
| 22 | - 32F57CB01D93CFFA00A6D031 /* CNLivePlayerSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32F57CAE1D93CFF500A6D031 /* CNLivePlayerSDK.framework */; }; | |
| 23 | - 32F57CB11D93CFFA00A6D031 /* CNLivePlayerSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 32F57CAE1D93CFF500A6D031 /* CNLivePlayerSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; | |
| 24 | 24 | /* End PBXBuildFile section */ |
| 25 | 25 | |
| 26 | 26 | /* Begin PBXCopyFilesBuildPhase section */ |
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | dstPath = ""; |
| 31 | 31 | dstSubfolderSpec = 10; |
| 32 | 32 | files = ( |
| 33 | - 32F57CB11D93CFFA00A6D031 /* CNLivePlayerSDK.framework in Embed Frameworks */, | |
| 33 | + 3228BEB01D9B969A002E600B /* CNLivePlayerSDK.framework in Embed Frameworks */, | |
| 34 | 34 | ); |
| 35 | 35 | name = "Embed Frameworks"; |
| 36 | 36 | runOnlyForDeploymentPostprocessing = 0; |
| ... | ... | @@ -38,6 +38,11 @@ |
| 38 | 38 | /* End PBXCopyFilesBuildPhase section */ |
| 39 | 39 | |
| 40 | 40 | /* Begin PBXFileReference section */ |
| 41 | + 3228BEAD1D9B9692002E600B /* CNLivePlayerSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLivePlayerSDK.framework; sourceTree = "<group>"; }; | |
| 42 | + 32B4C8581D9B66A400925AF0 /* CNLiveViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveViewController.h; sourceTree = "<group>"; }; | |
| 43 | + 32B4C8591D9B66A400925AF0 /* CNLiveViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveViewController.m; sourceTree = "<group>"; }; | |
| 44 | + 32B4C85B1D9B66E500925AF0 /* StreamerDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamerDetailViewController.h; sourceTree = "<group>"; }; | |
| 45 | + 32B4C85C1D9B66E500925AF0 /* StreamerDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StreamerDetailViewController.m; sourceTree = "<group>"; }; | |
| 41 | 46 | 32E6CA261D5B0AF400B58EBC /* CNLivePlayerSDKTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CNLivePlayerSDKTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; |
| 42 | 47 | 32E6CA2A1D5B0AF400B58EBC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; |
| 43 | 48 | 32E6CA2C1D5B0AF400B58EBC /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; |
| ... | ... | @@ -50,17 +55,12 @@ |
| 50 | 55 | 32E6CA3A1D5B0AF400B58EBC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; |
| 51 | 56 | 32E6CA821D5B2AF700B58EBC /* BarrageViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BarrageViewController.h; sourceTree = "<group>"; }; |
| 52 | 57 | 32E6CA831D5B2AF700B58EBC /* BarrageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BarrageViewController.m; sourceTree = "<group>"; }; |
| 53 | - 32E6CA851D5B2AF700B58EBC /* CNLiveViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveViewController.h; sourceTree = "<group>"; }; | |
| 54 | - 32E6CA861D5B2AF700B58EBC /* CNLiveViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveViewController.m; sourceTree = "<group>"; }; | |
| 55 | 58 | 32E6CA871D5B2AF700B58EBC /* NormalViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NormalViewController.h; sourceTree = "<group>"; }; |
| 56 | 59 | 32E6CA881D5B2AF700B58EBC /* NormalViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NormalViewController.m; sourceTree = "<group>"; }; |
| 57 | 60 | 32E6CA891D5B2AF700B58EBC /* PlayerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayerViewController.h; sourceTree = "<group>"; }; |
| 58 | 61 | 32E6CA8A1D5B2AF700B58EBC /* PlayerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlayerViewController.m; sourceTree = "<group>"; }; |
| 59 | - 32E6CA8C1D5B2AF700B58EBC /* StreamerDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamerDetailViewController.h; sourceTree = "<group>"; }; | |
| 60 | - 32E6CA8D1D5B2AF700B58EBC /* StreamerDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StreamerDetailViewController.m; sourceTree = "<group>"; }; | |
| 61 | 62 | 32E6CA8E1D5B2AF700B58EBC /* StreamerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamerViewController.h; sourceTree = "<group>"; }; |
| 62 | 63 | 32E6CA8F1D5B2AF700B58EBC /* StreamerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StreamerViewController.m; sourceTree = "<group>"; }; |
| 63 | - 32F57CAE1D93CFF500A6D031 /* CNLivePlayerSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLivePlayerSDK.framework; sourceTree = "<group>"; }; | |
| 64 | 64 | /* End PBXFileReference section */ |
| 65 | 65 | |
| 66 | 66 | /* Begin PBXFrameworksBuildPhase section */ |
| ... | ... | @@ -68,7 +68,7 @@ |
| 68 | 68 | isa = PBXFrameworksBuildPhase; |
| 69 | 69 | buildActionMask = 2147483647; |
| 70 | 70 | files = ( |
| 71 | - 32F57CB01D93CFFA00A6D031 /* CNLivePlayerSDK.framework in Frameworks */, | |
| 71 | + 3228BEAF1D9B969A002E600B /* CNLivePlayerSDK.framework in Frameworks */, | |
| 72 | 72 | ); |
| 73 | 73 | runOnlyForDeploymentPostprocessing = 0; |
| 74 | 74 | }; |
| ... | ... | @@ -78,7 +78,7 @@ |
| 78 | 78 | 32E6CA1D1D5B0AF400B58EBC = { |
| 79 | 79 | isa = PBXGroup; |
| 80 | 80 | children = ( |
| 81 | - 32F57CAE1D93CFF500A6D031 /* CNLivePlayerSDK.framework */, | |
| 81 | + 3228BEAD1D9B9692002E600B /* CNLivePlayerSDK.framework */, | |
| 82 | 82 | 32E6CA281D5B0AF400B58EBC /* CNLivePlayerSDKTest */, |
| 83 | 83 | 32E6CA271D5B0AF400B58EBC /* Products */, |
| 84 | 84 | ); |
| ... | ... | @@ -131,8 +131,8 @@ |
| 131 | 131 | 32E6CA841D5B2AF700B58EBC /* Player */ = { |
| 132 | 132 | isa = PBXGroup; |
| 133 | 133 | children = ( |
| 134 | - 32E6CA851D5B2AF700B58EBC /* CNLiveViewController.h */, | |
| 135 | - 32E6CA861D5B2AF700B58EBC /* CNLiveViewController.m */, | |
| 134 | + 32B4C8581D9B66A400925AF0 /* CNLiveViewController.h */, | |
| 135 | + 32B4C8591D9B66A400925AF0 /* CNLiveViewController.m */, | |
| 136 | 136 | 32E6CA871D5B2AF700B58EBC /* NormalViewController.h */, |
| 137 | 137 | 32E6CA881D5B2AF700B58EBC /* NormalViewController.m */, |
| 138 | 138 | 32E6CA891D5B2AF700B58EBC /* PlayerViewController.h */, |
| ... | ... | @@ -144,8 +144,8 @@ |
| 144 | 144 | 32E6CA8B1D5B2AF700B58EBC /* Streamer */ = { |
| 145 | 145 | isa = PBXGroup; |
| 146 | 146 | children = ( |
| 147 | - 32E6CA8C1D5B2AF700B58EBC /* StreamerDetailViewController.h */, | |
| 148 | - 32E6CA8D1D5B2AF700B58EBC /* StreamerDetailViewController.m */, | |
| 147 | + 32B4C85B1D9B66E500925AF0 /* StreamerDetailViewController.h */, | |
| 148 | + 32B4C85C1D9B66E500925AF0 /* StreamerDetailViewController.m */, | |
| 149 | 149 | 32E6CA8E1D5B2AF700B58EBC /* StreamerViewController.h */, |
| 150 | 150 | 32E6CA8F1D5B2AF700B58EBC /* StreamerViewController.m */, |
| 151 | 151 | ); |
| ... | ... | @@ -227,11 +227,11 @@ |
| 227 | 227 | 32E6CA931D5B2AF700B58EBC /* PlayerViewController.m in Sources */, |
| 228 | 228 | 32E6CA311D5B0AF400B58EBC /* ViewController.m in Sources */, |
| 229 | 229 | 32E6CA951D5B2AF700B58EBC /* StreamerViewController.m in Sources */, |
| 230 | - 32E6CA911D5B2AF700B58EBC /* CNLiveViewController.m in Sources */, | |
| 231 | 230 | 32E6CA901D5B2AF700B58EBC /* BarrageViewController.m in Sources */, |
| 231 | + 32B4C85D1D9B66E500925AF0 /* StreamerDetailViewController.m in Sources */, | |
| 232 | + 32B4C85A1D9B66A400925AF0 /* CNLiveViewController.m in Sources */, | |
| 232 | 233 | 32E6CA2E1D5B0AF400B58EBC /* AppDelegate.m in Sources */, |
| 233 | 234 | 32E6CA2B1D5B0AF400B58EBC /* main.m in Sources */, |
| 234 | - 32E6CA941D5B2AF700B58EBC /* StreamerDetailViewController.m in Sources */, | |
| 235 | 235 | 32E6CA921D5B2AF700B58EBC /* NormalViewController.m in Sources */, |
| 236 | 236 | ); |
| 237 | 237 | runOnlyForDeploymentPostprocessing = 0; | ... | ... |
CNLivePlayerSDKTest/CNLivePlayerSDKTest/Player/CNLiveViewController.m
| ... | ... | @@ -29,26 +29,46 @@ |
| 29 | 29 | |
| 30 | 30 | self.view.backgroundColor = [UIColor grayColor]; |
| 31 | 31 | |
| 32 | + //用来更新视频当前播放时间 | |
| 32 | 33 | _currentTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(timeChange) userInfo:nil repeats:YES]; |
| 33 | 34 | |
| 35 | + //添加播放器通知 | |
| 34 | 36 | [self installMovieNotificationObservers]; |
| 35 | - //直播播放 | |
| 36 | - _player = [[CNLiveMoviePlayerController alloc] initLivePlayWithAppId:@"60_irg1rhs308" appKey:@"4e7a37b27a717a9e9b0a7aea4620ee55ea61fbf923bf46" channelId:@"d849bb4277be42799df3ffc21654d949" completion:^{ | |
| 37 | - _player.shouldUseHWCodec = YES; | |
| 38 | - _player.view.frame = CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.width*9/16); | |
| 39 | - _player.shouldAutoplay = YES; | |
| 40 | - [_player prepareToPlay]; | |
| 41 | - [self.view addSubview:_player.view]; | |
| 42 | - }]; | |
| 43 | 37 | |
| 44 | - /* 点播播放 | |
| 45 | - _player = [[CNLiveMoviePlayerController alloc] initVodPlayWithAppId:@"60_irg1rhs308" appKey:@"4e7a37b27a717a9e9b0a7aea4620ee55ea61fbf923bf46" vId:@"aaa123"]; | |
| 46 | - _player.shouldUseHWCodec = YES; | |
| 47 | - _player.view.frame = CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.width*9/16); | |
| 48 | - _player.shouldAutoplay = YES; | |
| 49 | - [_player prepareToPlay]; | |
| 50 | - [self.view addSubview:_player.view]; | |
| 51 | - */ | |
| 38 | + //获取SDK版本号 | |
| 39 | + NSLog(@">>>>>>>>>>>>%@", [CNLiveMoviePlayerController getVersion]); | |
| 40 | + | |
| 41 | + //点播播放 | |
| 42 | + _player = [[CNLiveMoviePlayerController alloc] initVodPlayWithAppId:@"60_irg1rhs308" | |
| 43 | + appKey:@"4e7a37b27a717a9e9b0a7aea4620ee55ea61fbf923bf46" | |
| 44 | + vId:@"aaa123" | |
| 45 | + authSuccess:^{ | |
| 46 | + | |
| 47 | + _player.shouldUseHWCodec = YES; | |
| 48 | + _player.view.frame = CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.width*9/16); | |
| 49 | + _player.shouldAutoplay = YES; | |
| 50 | + [_player prepareToPlay]; | |
| 51 | + [self.view addSubview:_player.view]; | |
| 52 | + | |
| 53 | + } authFailed:^(NSDictionary *errorInfo) { | |
| 54 | + NSLog(@"初始化点播播放器失败%@", errorInfo); | |
| 55 | + }]; | |
| 56 | + | |
| 57 | + //直播播放 | |
| 58 | +// _player = [[CNLiveMoviePlayerController alloc] initLivePlayWithAppId:@"60_irg1rhs308" | |
| 59 | +// appKey:@"4e7a37b27a717a9e9b0a7aea4620ee55ea61fbf923bf46" | |
| 60 | +// channelId:@"news" | |
| 61 | +// authSuccess:^{ | |
| 62 | +// | |
| 63 | +// _player.shouldUseHWCodec = YES; | |
| 64 | +// _player.view.frame = CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.width*9/16); | |
| 65 | +// _player.shouldAutoplay = YES; | |
| 66 | +// [_player prepareToPlay]; | |
| 67 | +// [self.view addSubview:_player.view]; | |
| 68 | +// | |
| 69 | +// } authFailed:^(NSDictionary *errorInfo) { | |
| 70 | +// NSLog(@"初始化直播播放器失败:%@", errorInfo); | |
| 71 | +// }]; | |
| 52 | 72 | |
| 53 | 73 | _playOrPauseBtn = [UIButton buttonWithType:UIButtonTypeSystem]; |
| 54 | 74 | _playOrPauseBtn.frame = CGRectMake(10, self.view.frame.size.width*9/16+20+50, 50, 50); |
| ... | ... | @@ -99,15 +119,6 @@ |
| 99 | 119 | [self dismissViewControllerAnimated:YES completion:NULL]; |
| 100 | 120 | } |
| 101 | 121 | |
| 102 | -- (void)prepareToPlay | |
| 103 | -{ | |
| 104 | - _player.shouldUseHWCodec = YES; | |
| 105 | - _player.view.frame = CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.width*9/16); | |
| 106 | - _player.shouldAutoplay = YES; | |
| 107 | - [_player prepareToPlay]; | |
| 108 | - [self.view addSubview:_player.view]; | |
| 109 | -} | |
| 110 | - | |
| 111 | 122 | - (void)changePlayBtnStatus:(BOOL)playing |
| 112 | 123 | { |
| 113 | 124 | if (playing) { |
| ... | ... | @@ -139,21 +150,25 @@ |
| 139 | 150 | |
| 140 | 151 | -(void)installMovieNotificationObservers //添加视频播放通知 |
| 141 | 152 | { |
| 153 | + //视频加载状态改变 | |
| 142 | 154 | [[NSNotificationCenter defaultCenter] addObserver:self |
| 143 | 155 | selector:@selector(loadStateDidChange:) |
| 144 | 156 | name:MPMoviePlayerLoadStateDidChangeNotification |
| 145 | 157 | object:nil]; |
| 146 | 158 | |
| 159 | + //视频播放错误及结束原因 | |
| 147 | 160 | [[NSNotificationCenter defaultCenter] addObserver:self |
| 148 | 161 | selector:@selector(moviePlayBackDidFinish:) |
| 149 | 162 | name:MPMoviePlayerPlaybackDidFinishNotification |
| 150 | 163 | object:nil]; |
| 151 | 164 | |
| 165 | + //视频缓冲至可播放状态 | |
| 152 | 166 | [[NSNotificationCenter defaultCenter] addObserver:self |
| 153 | 167 | selector:@selector(mediaIsPreparedToPlayDidChange:) |
| 154 | 168 | name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification |
| 155 | 169 | object:nil]; |
| 156 | 170 | |
| 171 | + //视频播放状态改变 | |
| 157 | 172 | [[NSNotificationCenter defaultCenter] addObserver:self |
| 158 | 173 | selector:@selector(moviePlayBackStateDidChange:) |
| 159 | 174 | name:MPMoviePlayerPlaybackStateDidChangeNotification | ... | ... |
CNLivePlayerSDKTest/CNLivePlayerSDKTest/Streamer/StreamerDetailViewController.m
| ... | ... | @@ -35,8 +35,12 @@ |
| 35 | 35 | if (_isAuthLive) { |
| 36 | 36 | |
| 37 | 37 | NSString *activityId = [NSString stringWithFormat:@"%d%d%d%d%d",arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9]; |
| 38 | + | |
| 38 | 39 | _kitCN = [[CNLiveGPUStreamerKit alloc] initWithDefaultConfigWithAppId:@"60_irg1rhs308" appKey:@"4e7a37b27a717a9e9b0a7aea4620ee55ea61fbf923bf46" activityId:activityId channelId:activityId isHorizontalScreen:@"0"]; |
| 39 | - _kitCN.activityName = @"中国网+测试"; | |
| 40 | +// _kitCN.activityName = @"iOS test"; | |
| 41 | + | |
| 42 | +// _kitCN.coverImgUrl = @"djfiwooa"; | |
| 43 | + | |
| 40 | 44 | |
| 41 | 45 | [_kitCN getStreamerURLWithSuccess:^{ |
| 42 | 46 | |
| ... | ... | @@ -50,6 +54,7 @@ |
| 50 | 54 | }]; |
| 51 | 55 | |
| 52 | 56 | }else{ |
| 57 | + | |
| 53 | 58 | _kitCN = [[CNLiveGPUStreamerKit alloc] initWithDefaultConfig]; |
| 54 | 59 | _hostURL = _url; |
| 55 | 60 | |
| ... | ... | @@ -58,17 +63,17 @@ |
| 58 | 63 | |
| 59 | 64 | } |
| 60 | 65 | |
| 61 | - _startLiveBtn = [self addButton:@"开始直播" frame:CGRectMake(80, 40, 60, 40) action:@selector(startCapture:)]; | |
| 66 | + _startLiveBtn = [self addButton:@"开始直播" frame:CGRectMake(100, 40, 80, 40) action:@selector(startCapture:)]; | |
| 62 | 67 | |
| 63 | - [self addButton:@"开启预览" frame:CGRectMake(10, 40, 60, 40) action:@selector(startPreview:)]; | |
| 68 | + [self addButton:@"开启预览" frame:CGRectMake(10, 40, 80, 40) action:@selector(startPreview:)]; | |
| 64 | 69 | |
| 65 | - [self addButton:@"退出" frame:CGRectMake(150, 40, 60, 40) action:@selector(quit)]; | |
| 70 | + [self addButton:@"退出" frame:CGRectMake(190, 40, 80, 40) action:@selector(quit)]; | |
| 66 | 71 | |
| 67 | - [self addButton:@"美颜" frame:CGRectMake(10, 100, 60, 40) action:@selector(openFilter:)]; | |
| 72 | + [self addButton:@"美颜" frame:CGRectMake(10, 100, 80, 40) action:@selector(openFilter:)]; | |
| 68 | 73 | |
| 69 | - [self addButton:@"摄像头" frame:CGRectMake(80, 100, 60, 40) action:@selector(changeCamera:)]; | |
| 74 | + [self addButton:@"摄像头" frame:CGRectMake(100, 100, 80, 40) action:@selector(changeCamera:)]; | |
| 70 | 75 | |
| 71 | - [self addButton:@"闪光灯" frame:CGRectMake(150, 100, 60, 40) action:@selector(openFlash)]; | |
| 76 | + [self addButton:@"闪光灯" frame:CGRectMake(190, 100, 80, 40) action:@selector(openFlash)]; | |
| 72 | 77 | |
| 73 | 78 | _stateLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 160, Width, 200)]; |
| 74 | 79 | _stateLab.backgroundColor = [UIColor clearColor]; |
| ... | ... | @@ -120,7 +125,7 @@ |
| 120 | 125 | [button setTitle:@"关闭预览" forState:UIControlStateNormal]; |
| 121 | 126 | }else{ |
| 122 | 127 | [button setTitle:@"开启预览" forState:UIControlStateNormal]; |
| 123 | - if (_startLiveBtn.selected) { | |
| 128 | + if (_kitCN.streamState == CNLiveStreamStateConnected) { | |
| 124 | 129 | [_kitCN stopStream]; |
| 125 | 130 | [_startLiveBtn setTitle:@"开始直播" forState:UIControlStateNormal]; |
| 126 | 131 | _startLiveBtn.selected = NO; |
| ... | ... | @@ -136,17 +141,21 @@ |
| 136 | 141 | if (button.selected) { |
| 137 | 142 | [button setTitle:@"停止直播" forState:UIControlStateNormal]; |
| 138 | 143 | if (_isAuthLive) { |
| 144 | + | |
| 139 | 145 | [_kitCN startStream:^{ |
| 140 | - NSLog(@"开始推流"); | |
| 146 | + NSLog(@"success"); | |
| 141 | 147 | } failure:^(NSError *error) { |
| 142 | 148 | [self toast:error.localizedDescription]; |
| 143 | 149 | }]; |
| 150 | + | |
| 144 | 151 | }else{ |
| 145 | 152 | [_kitCN startStream:_hostURL]; |
| 146 | 153 | } |
| 147 | 154 | }else{ |
| 148 | 155 | _stateLab.text = nil; |
| 156 | + | |
| 149 | 157 | [_kitCN stopStream]; |
| 158 | + | |
| 150 | 159 | [button setTitle:@"开始直播" forState:UIControlStateNormal]; |
| 151 | 160 | } |
| 152 | 161 | } |
| ... | ... | @@ -159,24 +168,30 @@ |
| 159 | 168 | |
| 160 | 169 | - (void)changeCamera:(UIButton *)button |
| 161 | 170 | { |
| 162 | - button.selected = !button.selected; | |
| 163 | - if (button.selected) { | |
| 164 | - _kitCN.cameraPosition = AVCaptureDevicePositionBack; | |
| 165 | - }else{ | |
| 166 | - _kitCN.cameraPosition = AVCaptureDevicePositionFront; | |
| 167 | - } | |
| 171 | +// button.selected = !button.selected; | |
| 172 | +// if (button.selected) { | |
| 173 | +// _kitCN.cameraPosition = AVCaptureDevicePositionBack; | |
| 174 | +// }else{ | |
| 175 | +// _kitCN.cameraPosition = AVCaptureDevicePositionFront; | |
| 176 | +// } | |
| 177 | + [_kitCN switchCamera]; | |
| 168 | 178 | } |
| 169 | 179 | |
| 170 | 180 | - (void)openFlash |
| 171 | 181 | { |
| 172 | 182 | [_kitCN toggleTorch]; |
| 183 | +// [_kitCN setTorchMode:AVCaptureTorchModeOn]; | |
| 173 | 184 | } |
| 174 | 185 | |
| 175 | 186 | - (void)quit |
| 176 | 187 | { |
| 177 | - [_kitCN stopStream]; | |
| 178 | - [_kitCN stopPreview]; | |
| 179 | - [[NSNotificationCenter defaultCenter] removeObserver:self]; | |
| 188 | + if (_kitCN.streamState == CNLiveStreamStateConnected) { | |
| 189 | + [_kitCN stopStream]; | |
| 190 | + } | |
| 191 | + if (_kitCN.captureState == CNLiveCaptureStateCapturing) { | |
| 192 | + [_kitCN stopPreview]; | |
| 193 | + } | |
| 194 | + | |
| 180 | 195 | [self dismissViewControllerAnimated:YES completion:NULL]; |
| 181 | 196 | } |
| 182 | 197 | |
| ... | ... | @@ -191,9 +206,33 @@ |
| 191 | 206 | selector:@selector(streamStateChange) |
| 192 | 207 | name:CNLiveStreamStateDidChangeNotification |
| 193 | 208 | object:nil]; |
| 209 | + | |
| 210 | + [[NSNotificationCenter defaultCenter] addObserver:self | |
| 211 | + selector:@selector(abnormalState) | |
| 212 | + name:CNLiveStreamAbnormalNotification | |
| 213 | + object:nil]; | |
| 214 | + | |
| 215 | + [[NSNotificationCenter defaultCenter] addObserver:self | |
| 216 | + selector:@selector(streamStopSuccess) | |
| 217 | + name:CNLiveStreamStopSuccessNotification | |
| 218 | + object:nil]; | |
| 219 | + | |
| 220 | + [[NSNotificationCenter defaultCenter] addObserver:self | |
| 221 | + selector:@selector(streamStopFailed) | |
| 222 | + name:CNLiveStreamStopFailedNotification | |
| 223 | + object:nil]; | |
| 194 | 224 | } |
| 195 | 225 | |
| 196 | 226 | #pragma mark - notification |
| 227 | +- (void)streamStopSuccess | |
| 228 | +{ | |
| 229 | + NSLog(@"---------CNLiveStreamStopSuccess"); | |
| 230 | +} | |
| 231 | + | |
| 232 | +- (void)streamStopFailed | |
| 233 | +{ | |
| 234 | + NSLog(@"---------CNLiveStreamStopFailed"); | |
| 235 | +} | |
| 197 | 236 | |
| 198 | 237 | - (void)captureStateChange |
| 199 | 238 | { |
| ... | ... | @@ -298,11 +337,13 @@ |
| 298 | 337 | [_kitCN stopStream]; |
| 299 | 338 | |
| 300 | 339 | if (_isAuthLive) { |
| 340 | + | |
| 301 | 341 | [_kitCN startStream:^{ |
| 302 | - NSLog(@"开始推流"); | |
| 342 | + NSLog(@"success"); | |
| 303 | 343 | } failure:^(NSError *error) { |
| 304 | 344 | [self toast:error.localizedDescription]; |
| 305 | 345 | }]; |
| 346 | + | |
| 306 | 347 | }else{ |
| 307 | 348 | [_kitCN startStream:_hostURL]; |
| 308 | 349 | } |
| ... | ... | @@ -310,6 +351,14 @@ |
| 310 | 351 | } |
| 311 | 352 | } |
| 312 | 353 | |
| 354 | +- (void)abnormalState | |
| 355 | +{ | |
| 356 | + [self toast:@"推流异常中断~~"]; | |
| 357 | + NSLog(@"---------推流异常中断~~"); | |
| 358 | + [_startLiveBtn setTitle:@"开始直播" forState:UIControlStateNormal]; | |
| 359 | + _startLiveBtn.selected = NO; | |
| 360 | +} | |
| 361 | + | |
| 313 | 362 | //对焦 |
| 314 | 363 | - (void)onTap:(UIGestureRecognizer *)sender |
| 315 | 364 | { |
| ... | ... | @@ -361,6 +410,11 @@ |
| 361 | 410 | return _captureView; |
| 362 | 411 | } |
| 363 | 412 | |
| 413 | +- (void)dealloc | |
| 414 | +{ | |
| 415 | + [[NSNotificationCenter defaultCenter] removeObserver:self]; | |
| 416 | + self.kitCN = nil; | |
| 417 | +} | |
| 364 | 418 | |
| 365 | 419 | - (void)didReceiveMemoryWarning { |
| 366 | 420 | [super didReceiveMemoryWarning]; | ... | ... |
CNLiveStreamer.pdf deleted
100644 → 0
No preview for this file type
推流SDK文档.pdf
0 → 100644
No preview for this file type
播放SDK文档.pdf
0 → 100644
No preview for this file type