Skip to content

Commit 82bdf51

Browse files
author
ianyanzhang
committed
1、Solve some bugs of download
1 parent 57918f3 commit 82bdf51

File tree

5 files changed

+69
-20
lines changed

5 files changed

+69
-20
lines changed

Demo/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def common_pods_all
2727
pod 'AFNetworking'
2828
pod 'BlocksKit', '~> 2.2.5'
2929
pod 'CWStatusBarNotification', '~> 2.3.5'
30-
pod 'TXLiteAVSDK_Player', '~> 10.9.13161'
30+
pod 'TXLiteAVSDK_Player', '~> 11.0.14028'
3131
end
3232

3333
def common_pods_smart

Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheListView/VideoCacheListCell.m

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ @interface VideoCacheListCell()
3434

3535
@property (nonatomic, strong) UILabel *cacheProgressLabel;
3636

37+
@property (nonatomic, strong) UILabel *sizeLabel;
38+
3739
@property (nonatomic, strong) UIView *statusView;
3840

3941
@property (nonatomic, strong) UILabel *statusLabel;
@@ -57,13 +59,20 @@ @implementation VideoCacheListCell
5759
+ (void)initialize {
5860
static dispatch_once_t onceToken;
5961
dispatch_once(&onceToken, ^{
60-
gQualityDic = @ {playerLocalize(@"SuperPlayerDemo.MoviePlayer.original") : @(TXVodQualityOD),
61-
playerLocalize(@"SuperPlayerDemo.MoviePlayer.smooth") : @(TXVodQualityFLU),
62-
playerLocalize(@"SuperPlayerDemo.MoviePlayer.SD") : @(TXVodQualitySD),
63-
playerLocalize(@"SuperPlayerDemo.MoviePlayer.HD") : @(TXVodQualityHD),
64-
playerLocalize(@"SuperPlayerDemo.MoviePlayer.FHD") : @(TXVodQualityFHD),
65-
playerLocalize(@"SuperPlayerDemo.MoviePlayer.2K") : @(TXVodQuality2K),
66-
playerLocalize(@"SuperPlayerDemo.MoviePlayer.4K") : @(TXVodQuality4K)};
62+
gQualityDic = @ {
63+
@(TXVodQualityOD) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.original"),
64+
@(TXVodQualityFLU) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.smooth"),
65+
@(TXVodQualitySD) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.SD"),
66+
@(TXVodQualityHD) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.HD"),
67+
@(TXVodQualityFHD) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.FHD"),
68+
@(TXVodQuality2K) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.2K"),
69+
@(TXVodQuality4K) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.4K"),
70+
@(TXVodQuality240P) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.smooth"),
71+
@(TXVodQuality360P) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.smooth"),
72+
@(TXVodQuality480P) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.SD"),
73+
@(TXVodQuality540P) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.SD"),
74+
@(TXVodQuality720P) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.HD"),
75+
@(TXVodQuality1080p) : playerLocalize(@"SuperPlayerDemo.MoviePlayer.HD")};
6776
});
6877
}
6978

@@ -96,12 +105,18 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
96105
make.width.mas_equalTo(140);
97106
}];
98107

108+
[self addSubview:self.sizeLabel];
109+
[self.sizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
110+
make.left.equalTo(self).offset(20 + 114 + 10);
111+
make.top.equalTo(self).offset(10 + 16 + 24 + 4);
112+
make.height.mas_equalTo(16);
113+
}];
114+
99115
[self addSubview:self.cacheProgressLabel];
100116
[self.cacheProgressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
101-
make.left.equalTo(self).offset(20 + 114 + 10);
117+
make.left.equalTo(self.sizeLabel.mas_right).offset(5);
102118
make.top.equalTo(self).offset(10 + 16 + 24 + 4);
103119
make.height.mas_equalTo(16);
104-
make.width.mas_equalTo(120);
105120
}];
106121

107122
[self addSubview:self.resolutionLabel];
@@ -145,7 +160,8 @@ - (void)setModel:(VideoCacheListModel *)model {
145160
[self updateQuality:dataSource.quality];
146161
[self updateProgress:self.mediaInfo.progress];
147162
[self updateCacheState:self.mediaInfo.downloadState];
148-
163+
CGFloat size = model.mediaInfo.size * 1.0f / 1024 / 1024;
164+
self.sizeLabel.text = [NSString stringWithFormat:@"%0.2fM",size];
149165
NSString *key = nil;
150166
if (dataSource.appId != 0 && dataSource.fileId.length != 0) {
151167
key = [NSString stringWithFormat:@"%d%@%ld",dataSource.appId,dataSource.fileId,(long)dataSource.quality];
@@ -233,11 +249,14 @@ - (void)stopDownload {
233249

234250
- (SuperPlayerModel *)getSuperPlayModel {
235251
SuperPlayerModel *playModel = [[SuperPlayerModel alloc] init];
236-
if (self.mediaInfo.playPath.length > 0 && self.mediaInfo.downloadState == TXVodDownloadMediaInfoStateFinish) {
252+
253+
254+
255+
if (self.mediaInfo.playPath.length > 0 && self.mediaInfo.downloadState == 4) {
237256
SuperPlayerUrl *playerUrl = [[SuperPlayerUrl alloc] init];
238257
[gQualityDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
239-
if ([obj integerValue] == self.mediaInfo.dataSource.quality) {
240-
playerUrl.title = key;
258+
if ([key integerValue] == self.mediaInfo.dataSource.quality) {
259+
playerUrl.title = obj;
241260
*stop = YES;
242261
}
243262
}];
@@ -275,8 +294,8 @@ - (SuperPlayerModel *)getSuperPlayModel {
275294
- (void)updateQuality:(NSInteger)quality {
276295
__weak __typeof(self) weakSelf = self;
277296
[gQualityDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
278-
if ([obj integerValue] == quality) {
279-
weakSelf.resolutionLabel.text = key;
297+
if ([key integerValue] == quality) {
298+
weakSelf.resolutionLabel.text = obj;
280299
*stop = YES;
281300
}
282301
}];
@@ -465,10 +484,24 @@ - (UILabel *)cacheProgressLabel {
465484
_cacheProgressLabel.font = [UIFont systemFontOfSize:12];
466485
_cacheProgressLabel.textColor = [UIColor grayColor];
467486
_cacheProgressLabel.textAlignment = NSTextAlignmentLeft;
487+
[_cacheProgressLabel setContentHuggingPriority:UILayoutPriorityRequired
488+
forAxis:UILayoutConstraintAxisHorizontal];
468489
}
469490
return _cacheProgressLabel;
470491
}
471492

493+
- (UILabel *)sizeLabel {
494+
if (!_sizeLabel) {
495+
_sizeLabel = [[UILabel alloc] init];
496+
_sizeLabel.font = [UIFont systemFontOfSize:12];
497+
_sizeLabel.textColor = [UIColor grayColor];
498+
_sizeLabel.textAlignment = NSTextAlignmentLeft;
499+
[_sizeLabel setContentHuggingPriority:UILayoutPriorityRequired
500+
forAxis:UILayoutConstraintAxisHorizontal];
501+
}
502+
return _sizeLabel;
503+
}
504+
472505
- (UILabel *)resolutionLabel {
473506
if (!_resolutionLabel) {
474507
_resolutionLabel = [[UILabel alloc] init];

Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheView.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,22 @@ - (TXVodDownloadMediaInfo *)getDownloadMediaInfo:(SuperPlayerModel *)model {
209209
}
210210

211211
- (int)getCurrentQuality {
212-
__block int quality;
212+
__block int quality = TXVodQuality720P;
213+
__block NSString *title;
213214
[self.currentModel.multiVideoURLs enumerateObjectsUsingBlock:^(SuperPlayerUrl * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
214215
if ([obj.title containsString:self.currentResolutionStr]) {
215216
quality = obj.qualityIndex;
217+
title = obj.title;
216218
*stop = YES;
217219
}
218220
}];
219-
221+
//根据分辨率指定清晰度
222+
NSArray *titlesArray = [title componentsSeparatedByString:@""];
223+
NSArray *resoluArray = [titlesArray.lastObject componentsSeparatedByString:@"P)"];
224+
NSString *resolution = resoluArray.firstObject;
225+
if(resolution.length > 0){
226+
quality = [resolution intValue];
227+
}
220228
return quality;
221229
}
222230

Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/MoviePlayerViewController.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,13 @@ - (void)_refreshVODList {
438438
[videoArray addObject:p];
439439
[_authParamArray addObject:videoArray];
440440

441+
videoArray = [NSMutableArray array];
442+
p = [[TXPlayerAuthParams alloc] init];
443+
p.appId = 1500005830;
444+
p.fileId = @"243791578431393746";
445+
[videoArray addObject:p];
446+
[_authParamArray addObject:videoArray];
447+
441448
videoArray = [NSMutableArray array];
442449
TXMoviePlayInfoResponse *trackInfoResponse = [[TXMoviePlayInfoResponse alloc] init];
443450
trackInfoResponse.name = playerLocalize(@"SuperPlayerDemo.MoviePlayer.multitrackvideo");

Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Localized/SuperPlayerLocalized.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
NSString *superPlayerLocalizeFromTable(NSString *key, NSString *table) {
1111
NSArray *languages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
1212
if ([languages count] <= 0) { // 语言包判断
13-
return key;
13+
languages = [NSArray arrayWithObject:@"en"];
1414
}
1515

1616
NSString *preferredLang = [languages objectAtIndex:0]; // zh-Hant-GB
@@ -24,7 +24,8 @@
2424
NSString *bundleOfPath = [NSBundle pathForResource:languageProj ofType:@"lproj" inDirectory:resourceDict];
2525
NSBundle *bundle = [NSBundle bundleWithPath:bundleOfPath];
2626
if (!bundle) { // 语言lproj的判断
27-
return key;
27+
bundleOfPath = [NSBundle pathForResource:@"en" ofType:@"lproj" inDirectory:resourceDict];
28+
bundle = [NSBundle bundleWithPath:bundleOfPath];
2829
}
2930

3031
return [bundle localizedStringForKey:key value:@"" table:table];

0 commit comments

Comments
 (0)