支持更多音视频格式,添加点播测试页面
This commit is contained in:
124
Example/SellyCloudSDK/Controllers/VOD/AVVodItemCell.m
Normal file
124
Example/SellyCloudSDK/Controllers/VOD/AVVodItemCell.m
Normal file
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// AVVodItemCell.m
|
||||
// SellyCloudSDK_Example
|
||||
//
|
||||
|
||||
#import "AVVodItemCell.h"
|
||||
#import "AVVodItemModel.h"
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
|
||||
@interface AVVodItemCell ()
|
||||
|
||||
@property (nonatomic, strong) UIImageView *thumbnailView;
|
||||
@property (nonatomic, strong) UIView *overlayView;
|
||||
@property (nonatomic, strong) UIImageView *playIcon;
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
@property (nonatomic, strong) UILabel *typeLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AVVodItemCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self setupUI];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupUI {
|
||||
self.contentView.backgroundColor = [UIColor secondarySystemBackgroundColor];
|
||||
self.contentView.layer.cornerRadius = 8;
|
||||
self.contentView.clipsToBounds = YES;
|
||||
|
||||
// Thumbnail
|
||||
_thumbnailView = [[UIImageView alloc] init];
|
||||
_thumbnailView.backgroundColor = [UIColor systemGray4Color];
|
||||
_thumbnailView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_thumbnailView.clipsToBounds = YES;
|
||||
[self.contentView addSubview:_thumbnailView];
|
||||
|
||||
// Overlay
|
||||
_overlayView = [[UIView alloc] init];
|
||||
_overlayView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2];
|
||||
[_thumbnailView addSubview:_overlayView];
|
||||
|
||||
// Play icon
|
||||
_playIcon = [[UIImageView alloc] initWithImage:[UIImage systemImageNamed:@"play.circle.fill"]];
|
||||
_playIcon.tintColor = [UIColor whiteColor];
|
||||
_playIcon.contentMode = UIViewContentModeScaleAspectFit;
|
||||
_playIcon.layer.shadowColor = [UIColor blackColor].CGColor;
|
||||
_playIcon.layer.shadowOffset = CGSizeMake(0, 2);
|
||||
_playIcon.layer.shadowOpacity = 0.3;
|
||||
_playIcon.layer.shadowRadius = 4;
|
||||
[_thumbnailView addSubview:_playIcon];
|
||||
|
||||
// Type label (badge on thumbnail)
|
||||
_typeLabel = [[UILabel alloc] init];
|
||||
_typeLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];
|
||||
_typeLabel.textColor = [UIColor whiteColor];
|
||||
_typeLabel.backgroundColor = [UIColor systemBlueColor];
|
||||
_typeLabel.textAlignment = NSTextAlignmentCenter;
|
||||
_typeLabel.layer.cornerRadius = 3;
|
||||
_typeLabel.clipsToBounds = YES;
|
||||
[_thumbnailView addSubview:_typeLabel];
|
||||
|
||||
// Title label
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightSemibold];
|
||||
_titleLabel.textColor = [UIColor labelColor];
|
||||
_titleLabel.numberOfLines = 2;
|
||||
[self.contentView addSubview:_titleLabel];
|
||||
|
||||
// Layout
|
||||
[_thumbnailView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.left.right.equalTo(self.contentView);
|
||||
make.height.equalTo(_thumbnailView.mas_width).multipliedBy(9.0 / 16.0).priority(750);
|
||||
}];
|
||||
|
||||
[_overlayView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(_thumbnailView);
|
||||
}];
|
||||
|
||||
[_playIcon mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.equalTo(_thumbnailView);
|
||||
make.width.height.equalTo(@44);
|
||||
}];
|
||||
|
||||
[_typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(_thumbnailView).offset(8);
|
||||
make.left.equalTo(_thumbnailView).offset(8);
|
||||
make.height.equalTo(@18);
|
||||
make.width.greaterThanOrEqualTo(@36);
|
||||
}];
|
||||
|
||||
[_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(_thumbnailView.mas_bottom).offset(8);
|
||||
make.left.equalTo(self.contentView).offset(8);
|
||||
make.right.equalTo(self.contentView).offset(-8);
|
||||
make.bottom.lessThanOrEqualTo(self.contentView).offset(-8).priority(750);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)configureWithModel:(AVVodItemModel *)model {
|
||||
_titleLabel.text = model.title;
|
||||
_typeLabel.text = [NSString stringWithFormat:@" %@ ", model.type.uppercaseString];
|
||||
|
||||
if (model.cover.length > 0) {
|
||||
NSURL *imageURL = [NSURL URLWithString:model.cover];
|
||||
[_thumbnailView sd_setImageWithURL:imageURL];
|
||||
} else {
|
||||
_thumbnailView.image = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)prepareForReuse {
|
||||
[super prepareForReuse];
|
||||
[_thumbnailView sd_cancelCurrentImageLoad];
|
||||
_thumbnailView.image = nil;
|
||||
_titleLabel.text = @"";
|
||||
_typeLabel.text = @"";
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user