@@ -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.2f M" ,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 ];
0 commit comments