Commit ed602afdd91f91947dca29f58ea02c35a0ef5f48
1 parent
3465c0ed
no message
Showing
2 changed files
with
8 additions
and
8 deletions
CNLivePlayer/Classes/Player/CNLivePlayer.h
CNLivePlayer/Classes/Player/CNLivePlayer.m
| ... | ... | @@ -18,6 +18,8 @@ |
| 18 | 18 | //缓存视频 |
| 19 | 19 | #import <KSYHTTPCache/HTTPCacheDefines.h> |
| 20 | 20 | #import "CNLiveHTTPProxyService.h" |
| 21 | +//缓存的key | |
| 22 | +#define PlayerStringToKey(a, b) [NSString stringWithFormat:@"%@:%@",a,b] | |
| 21 | 23 | |
| 22 | 24 | @interface CNLivePlayer () { |
| 23 | 25 | NSString *_idName; |
| ... | ... | @@ -83,6 +85,7 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang |
| 83 | 85 | } |
| 84 | 86 | |
| 85 | 87 | /* 初始化点播播放器 初始化成功后才能对播放器进行设置(如:自动播放、是否开启硬件解码等)和调用准备播放视频方法(prepareToPlay) |
| 88 | + * 码率默认2-标清 | |
| 86 | 89 | * |
| 87 | 90 | * videoId 点播视频Id |
| 88 | 91 | * authSuccess 初始化成功block |
| ... | ... | @@ -318,8 +321,7 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang |
| 318 | 321 | |
| 319 | 322 | #pragma mark - 查找本地是否有缓存url |
| 320 | 323 | - (void)getUrlSuccess:(void (^)(void))authSuccessBlock failure:(void (^)(NSDictionary *errorDic))authFailureBlock { |
| 321 | - NSString *key = [NSString stringWithFormat:@"%@:%@",_contentId,_rate]; | |
| 322 | - id data = [[CNLivePlayerDBTool shared] searchInTable:key]; | |
| 324 | + id data = [[CNLivePlayerDBTool shared] searchInTable:PlayerStringToKey(_contentId,_rate)]; | |
| 323 | 325 | CNLivePlayerDBModel *model = (CNLivePlayerDBModel *)data; |
| 324 | 326 | //1.判断是否存在缓存url |
| 325 | 327 | if (![model isEmpty]) { |
| ... | ... | @@ -478,8 +480,7 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang |
| 478 | 480 | if(!strongSelf){ |
| 479 | 481 | return ; |
| 480 | 482 | } |
| 481 | - NSString *key = [NSString stringWithFormat:@"%@:%@",strongSelf->_contentId, strongSelf->_rate]; | |
| 482 | - CNLivePlayerDBModel *model = [[CNLivePlayerDBModel alloc]initWithContenId:key url:videoURL]; | |
| 483 | + CNLivePlayerDBModel *model = [[CNLivePlayerDBModel alloc]initWithContenId:PlayerStringToKey(strongSelf->_contentId, strongSelf->_rate) url:videoURL]; | |
| 483 | 484 | [[CNLivePlayerDBTool shared] insertTable:model]; |
| 484 | 485 | |
| 485 | 486 | __weak typeof(self) weakSelf = strongSelf; |
| ... | ... | @@ -550,8 +551,7 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang |
| 550 | 551 | url = videoUrl; |
| 551 | 552 | |
| 552 | 553 | } |
| 553 | - NSString *key = [NSString stringWithFormat:@"%@:%@",strongSelf->_contentId, strongSelf->_rate]; | |
| 554 | - CNLivePlayerDBModel *model = [[CNLivePlayerDBModel alloc]initWithContenId:key url:url]; | |
| 554 | + CNLivePlayerDBModel *model = [[CNLivePlayerDBModel alloc]initWithContenId:PlayerStringToKey(strongSelf->_contentId, strongSelf->_rate) url:url]; | |
| 555 | 555 | [[CNLivePlayerDBTool shared] insertTable:model]; |
| 556 | 556 | |
| 557 | 557 | __weak typeof(self) weakSelf = strongSelf; |
| ... | ... | @@ -747,8 +747,7 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang |
| 747 | 747 | dispatch_async(dispatch_get_main_queue(), ^{ |
| 748 | 748 | __strong typeof(self) strongSelf = weakSelf; |
| 749 | 749 | if(strongSelf){ |
| 750 | - NSString *key = [NSString stringWithFormat:@"%@:%@",strongSelf->_contentId, strongSelf->_rate]; | |
| 751 | - [[CNLivePlayerDBTool shared] updateInTable:key]; | |
| 750 | + [[CNLivePlayerDBTool shared] updateInTable:PlayerStringToKey(strongSelf->_contentId, strongSelf->_rate)]; | |
| 752 | 751 | } |
| 753 | 752 | |
| 754 | 753 | }); | ... | ... |