diff --git a/Demo/Podfile b/Demo/Podfile index a5f526f..0c68426 100644 --- a/Demo/Podfile +++ b/Demo/Podfile @@ -27,7 +27,7 @@ def common_pods_all pod 'AFNetworking' pod 'BlocksKit', '~> 2.2.5' pod 'CWStatusBarNotification', '~> 2.3.5' - pod 'TXLiteAVSDK_Player', '~> 10.9.13161' + pod 'TXLiteAVSDK_Player', '~> 11.0.14028' end def common_pods_smart diff --git a/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheListView/VideoCacheListCell.m b/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheListView/VideoCacheListCell.m index 39578ba..c30b055 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheListView/VideoCacheListCell.m +++ b/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheListView/VideoCacheListCell.m @@ -34,6 +34,8 @@ @interface VideoCacheListCell() @property (nonatomic, strong) UILabel *cacheProgressLabel; +@property (nonatomic, strong) UILabel *sizeLabel; + @property (nonatomic, strong) UIView *statusView; @property (nonatomic, strong) UILabel *statusLabel; @@ -57,13 +59,20 @@ @implementation VideoCacheListCell + (void)initialize { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - gQualityDic = @ {playerLocalize(@"SuperPlayerDemo.MoviePlayer.original") : @(TXVodQualityOD), - playerLocalize(@"SuperPlayerDemo.MoviePlayer.smooth") : @(TXVodQualityFLU), - playerLocalize(@"SuperPlayerDemo.MoviePlayer.SD") : @(TXVodQualitySD), - playerLocalize(@"SuperPlayerDemo.MoviePlayer.HD") : @(TXVodQualityHD), - playerLocalize(@"SuperPlayerDemo.MoviePlayer.FHD") : @(TXVodQualityFHD), - playerLocalize(@"SuperPlayerDemo.MoviePlayer.2K") : @(TXVodQuality2K), - playerLocalize(@"SuperPlayerDemo.MoviePlayer.4K") : @(TXVodQuality4K)}; + gQualityDic = @ { + @(TXVodQualityOD) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.original"), + @(TXVodQualityFLU) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.smooth"), + @(TXVodQualitySD) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.SD"), + @(TXVodQualityHD) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.HD"), + @(TXVodQualityFHD) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.FHD"), + @(TXVodQuality2K) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.2K"), + @(TXVodQuality4K) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.4K"), + @(TXVodQuality240P) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.smooth"), + @(TXVodQuality360P) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.smooth"), + @(TXVodQuality480P) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.SD"), + @(TXVodQuality540P) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.SD"), + @(TXVodQuality720P) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.HD"), + @(TXVodQuality1080p) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.HD")}; }); } @@ -96,12 +105,18 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr make.width.mas_equalTo(140); }]; + [self addSubview:self.sizeLabel]; + [self.sizeLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.equalTo(self).offset(20 + 114 + 10); + make.top.equalTo(self).offset(10 + 16 + 24 + 4); + make.height.mas_equalTo(16); + }]; + [self addSubview:self.cacheProgressLabel]; [self.cacheProgressLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.equalTo(self).offset(20 + 114 + 10); + make.left.equalTo(self.sizeLabel.mas_right).offset(5); make.top.equalTo(self).offset(10 + 16 + 24 + 4); make.height.mas_equalTo(16); - make.width.mas_equalTo(120); }]; [self addSubview:self.resolutionLabel]; @@ -145,7 +160,8 @@ - (void)setModel:(VideoCacheListModel *)model { [self updateQuality:dataSource.quality]; [self updateProgress:self.mediaInfo.progress]; [self updateCacheState:self.mediaInfo.downloadState]; - + CGFloat size = model.mediaInfo.size * 1.0f / 1024 / 1024; + self.sizeLabel.text = [NSString stringWithFormat:@"%0.2fM",size]; NSString *key = nil; if (dataSource.appId != 0 && dataSource.fileId.length != 0) { key = [NSString stringWithFormat:@"%d%@%ld",dataSource.appId,dataSource.fileId,(long)dataSource.quality]; @@ -233,11 +249,14 @@ - (void)stopDownload { - (SuperPlayerModel *)getSuperPlayModel { SuperPlayerModel *playModel = [[SuperPlayerModel alloc] init]; - if (self.mediaInfo.playPath.length > 0 && self.mediaInfo.downloadState == TXVodDownloadMediaInfoStateFinish) { + + + + if (self.mediaInfo.playPath.length > 0 && self.mediaInfo.downloadState == 4) { SuperPlayerUrl *playerUrl = [[SuperPlayerUrl alloc] init]; [gQualityDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { - if ([obj integerValue] == self.mediaInfo.dataSource.quality) { - playerUrl.title = key; + if ([key integerValue] == self.mediaInfo.dataSource.quality) { + playerUrl.title = obj; *stop = YES; } }]; @@ -275,8 +294,8 @@ - (SuperPlayerModel *)getSuperPlayModel { - (void)updateQuality:(NSInteger)quality { __weak __typeof(self) weakSelf = self; [gQualityDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { - if ([obj integerValue] == quality) { - weakSelf.resolutionLabel.text = key; + if ([key integerValue] == quality) { + weakSelf.resolutionLabel.text = obj; *stop = YES; } }]; @@ -465,10 +484,24 @@ - (UILabel *)cacheProgressLabel { _cacheProgressLabel.font = [UIFont systemFontOfSize:12]; _cacheProgressLabel.textColor = [UIColor grayColor]; _cacheProgressLabel.textAlignment = NSTextAlignmentLeft; + [_cacheProgressLabel setContentHuggingPriority:UILayoutPriorityRequired + forAxis:UILayoutConstraintAxisHorizontal]; } return _cacheProgressLabel; } +- (UILabel *)sizeLabel { + if (!_sizeLabel) { + _sizeLabel = [[UILabel alloc] init]; + _sizeLabel.font = [UIFont systemFontOfSize:12]; + _sizeLabel.textColor = [UIColor grayColor]; + _sizeLabel.textAlignment = NSTextAlignmentLeft; + [_sizeLabel setContentHuggingPriority:UILayoutPriorityRequired + forAxis:UILayoutConstraintAxisHorizontal]; + } + return _sizeLabel; +} + - (UILabel *)resolutionLabel { if (!_resolutionLabel) { _resolutionLabel = [[UILabel alloc] init]; diff --git a/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheView.m b/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheView.m index 18fe76c..be01cbd 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheView.m +++ b/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheView.m @@ -209,14 +209,22 @@ - (TXVodDownloadMediaInfo *)getDownloadMediaInfo:(SuperPlayerModel *)model { } - (int)getCurrentQuality { - __block int quality; + __block int quality = TXVodQuality720P; + __block NSString *title; [self.currentModel.multiVideoURLs enumerateObjectsUsingBlock:^(SuperPlayerUrl * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj.title containsString:self.currentResolutionStr]) { quality = obj.qualityIndex; + title = obj.title; *stop = YES; } }]; - + //根据分辨率指定清晰度 + NSArray *titlesArray = [title componentsSeparatedByString:@"("]; + NSArray *resoluArray = [titlesArray.lastObject componentsSeparatedByString:@"P)"]; + NSString *resolution = resoluArray.firstObject; + if(resolution.length > 0){ + quality = [resolution intValue]; + } return quality; } diff --git a/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/MoviePlayerViewController.m b/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/MoviePlayerViewController.m index 51fa20d..7b96289 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/MoviePlayerViewController.m +++ b/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/MoviePlayerViewController.m @@ -438,6 +438,13 @@ - (void)_refreshVODList { [videoArray addObject:p]; [_authParamArray addObject:videoArray]; + videoArray = [NSMutableArray array]; + p = [[TXPlayerAuthParams alloc] init]; + p.appId = 1500005830; + p.fileId = @"243791578431393746"; + [videoArray addObject:p]; + [_authParamArray addObject:videoArray]; + videoArray = [NSMutableArray array]; TXMoviePlayInfoResponse *trackInfoResponse = [[TXMoviePlayInfoResponse alloc] init]; trackInfoResponse.name = playerLocalize(@"SuperPlayerDemo.MoviePlayer.multitrackvideo"); diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Localized/SuperPlayerLocalized.m b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Localized/SuperPlayerLocalized.m index 3ec262a..b8952e0 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Localized/SuperPlayerLocalized.m +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Localized/SuperPlayerLocalized.m @@ -10,7 +10,7 @@ NSString *superPlayerLocalizeFromTable(NSString *key, NSString *table) { NSArray *languages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"]; if ([languages count] <= 0) { // 语言包判断 - return key; + languages = [NSArray arrayWithObject:@"en"]; } NSString *preferredLang = [languages objectAtIndex:0]; // zh-Hant-GB @@ -24,7 +24,8 @@ NSString *bundleOfPath = [NSBundle pathForResource:languageProj ofType:@"lproj" inDirectory:resourceDict]; NSBundle *bundle = [NSBundle bundleWithPath:bundleOfPath]; if (!bundle) { // 语言lproj的判断 - return key; + bundleOfPath = [NSBundle pathForResource:@"en" ofType:@"lproj" inDirectory:resourceDict]; + bundle = [NSBundle bundleWithPath:bundleOfPath]; } return [bundle localizedStringForKey:key value:@"" table:table];