Commit 850294d4f177f28b13cb0033a3917d694f55bd8a
1 parent
62d043e5
no message
Showing
2 changed files
with
41 additions
and
6 deletions
CNLivePlayer/Classes/Player/CNLivePlayer.h
| @@ -17,8 +17,8 @@ | @@ -17,8 +17,8 @@ | ||
| 17 | 17 | ||
| 18 | NS_ASSUME_NONNULL_BEGIN | 18 | NS_ASSUME_NONNULL_BEGIN |
| 19 | // 切换直播视频 | 19 | // 切换直播视频 |
| 20 | -// v:videoId a:activityId | ||
| 21 | -#define PlayerLiveVideoId(v, a) [NSString stringWithFormat:@"%@:%@",v,a] | 20 | +// a:activityId c:channelId |
| 21 | +#define PlayerLiveVideoId(a, c) [NSString stringWithFormat:@"%@:%@", a, c] | ||
| 22 | 22 | ||
| 23 | typedef void (^SuccessBlock) (void); | 23 | typedef void (^SuccessBlock) (void); |
| 24 | typedef void (^FailureBlock) (NSError *error); | 24 | typedef void (^FailureBlock) (NSError *error); |
| @@ -89,6 +89,17 @@ typedef void (^AnchorStatus)(CNLiveAnchorStatus status); | @@ -89,6 +89,17 @@ typedef void (^AnchorStatus)(CNLiveAnchorStatus status); | ||
| 89 | */ | 89 | */ |
| 90 | - (void)switchVideo:(NSString *)videoId type:(CNLivePlayerDataType)type; | 90 | - (void)switchVideo:(NSString *)videoId type:(CNLivePlayerDataType)type; |
| 91 | 91 | ||
| 92 | +/** | ||
| 93 | +切换视频 | ||
| 94 | + | ||
| 95 | +@param videoId 视频id 直播视频videoId <- activityId:channelId 点播视频videoId <- videoId | ||
| 96 | +@param rate 视频码率 默认是@"2" | ||
| 97 | +@param type 视频类型 vod 点播视频 live 直播视频 | ||
| 98 | + | ||
| 99 | +@since v0.0.1 | ||
| 100 | +*/ | ||
| 101 | +- (void)switchVideo:(NSString *)videoId rate:(NSString *)rate type:(CNLivePlayerDataType)type; | ||
| 102 | + | ||
| 92 | #pragma mark - 切换码率 | 103 | #pragma mark - 切换码率 |
| 93 | /** | 104 | /** |
| 94 | 切换码率 | 105 | 切换码率 |
CNLivePlayer/Classes/Player/CNLivePlayer.m
| @@ -182,20 +182,41 @@ NSString * const CNLiveAnchorStatusChangedNotification = @"CNLiveAnchorStatusCha | @@ -182,20 +182,41 @@ NSString * const CNLiveAnchorStatusChangedNotification = @"CNLiveAnchorStatusCha | ||
| 182 | @since v0.0.1 | 182 | @since v0.0.1 |
| 183 | */ | 183 | */ |
| 184 | - (void)switchVideo:(NSString *)videoId type:(CNLivePlayerDataType)type { | 184 | - (void)switchVideo:(NSString *)videoId type:(CNLivePlayerDataType)type { |
| 185 | + [self switchVideo:videoId rate:@"2" type:type]; | ||
| 186 | +} | ||
| 187 | + | ||
| 188 | +/** | ||
| 189 | +切换视频 | ||
| 190 | + | ||
| 191 | +@param videoId 视频id 直播视频videoId <- activityId:channelId 点播视频videoId <- videoId | ||
| 192 | +@param rate 视频码率 默认是@"2" | ||
| 193 | +@param type 视频类型 vod 点播视频 live 直播视频 | ||
| 194 | + | ||
| 195 | +@since v0.0.1 | ||
| 196 | +*/ | ||
| 197 | +- (void)switchVideo:(NSString *)videoId rate:(NSString *)rate type:(CNLivePlayerDataType)type{ | ||
| 185 | if ([_videoId isEqualToString:videoId]) { | 198 | if ([_videoId isEqualToString:videoId]) { |
| 186 | return; | 199 | return; |
| 187 | } | 200 | } |
| 188 | - _rate = @"2"; | 201 | + |
| 202 | + if ([rate isEqualToString:@""]||!rate) { | ||
| 203 | + _rate = @"2"; | ||
| 204 | + | ||
| 205 | + }else{ | ||
| 206 | + _rate = rate; | ||
| 207 | + | ||
| 208 | + } | ||
| 189 | _switchRate = NO; | 209 | _switchRate = NO; |
| 190 | switch (type) { | 210 | switch (type) { |
| 191 | case CNLivePlayerDataTypeVod: | 211 | case CNLivePlayerDataTypeVod: |
| 192 | { | 212 | { |
| 193 | - _type = @"vod"; | ||
| 194 | _videoId = videoId; | 213 | _videoId = videoId; |
| 195 | _activityId = @""; | 214 | _activityId = @""; |
| 196 | _channelId = @""; | 215 | _channelId = @""; |
| 216 | + _type = @"vod"; | ||
| 197 | } | 217 | } |
| 198 | break; | 218 | break; |
| 219 | + | ||
| 199 | case CNLivePlayerDataTypeLive: | 220 | case CNLivePlayerDataTypeLive: |
| 200 | { | 221 | { |
| 201 | NSArray *array = [videoId componentsSeparatedByString:@":"]; | 222 | NSArray *array = [videoId componentsSeparatedByString:@":"]; |
| @@ -207,16 +228,19 @@ NSString * const CNLiveAnchorStatusChangedNotification = @"CNLiveAnchorStatusCha | @@ -207,16 +228,19 @@ NSString * const CNLiveAnchorStatusChangedNotification = @"CNLiveAnchorStatusCha | ||
| 207 | _type = @"live"; | 228 | _type = @"live"; |
| 208 | } | 229 | } |
| 209 | break; | 230 | break; |
| 231 | + | ||
| 210 | case CNLivePlayerDataTypeAudio: | 232 | case CNLivePlayerDataTypeAudio: |
| 211 | { | 233 | { |
| 212 | - _type = @"vod"; | ||
| 213 | _videoId = videoId; | 234 | _videoId = videoId; |
| 235 | + _type = @"vod"; | ||
| 214 | } | 236 | } |
| 215 | break; | 237 | break; |
| 238 | + | ||
| 216 | } | 239 | } |
| 217 | [self getCacheURLSuccess:nil failure:nil]; | 240 | [self getCacheURLSuccess:nil failure:nil]; |
| 218 | - | 241 | + |
| 219 | } | 242 | } |
| 243 | + | ||
| 220 | #pragma mark - 切换码率 | 244 | #pragma mark - 切换码率 |
| 221 | /** | 245 | /** |
| 222 | 切换码率 | 246 | 切换码率 |