//
|
// PBVideoCollectionViewCell.m
|
// IphoneBIMe
|
//
|
// Created by zjf on 2020/8/25.
|
// Copyright © 2020 ProBIM. All rights reserved.
|
//
|
|
#import "PBVideoCollectionViewCell.h"
|
@interface PBVideoCollectionViewCell()
|
@property (nonatomic, weak) UIImageView *imageV;
|
@property (nonatomic, weak) UIButton *playBtn;
|
@end
|
@implementation PBVideoCollectionViewCell
|
- (instancetype)initWithFrame:(CGRect)frame {
|
if (self = [super initWithFrame:frame]) {
|
[self setupUI];
|
}
|
return self;
|
}
|
- (void)setupUI {
|
UIImageView *imageV = [[UIImageView alloc] init];
|
[self.contentView addSubview:imageV];
|
[imageV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.bottom.left.right.equalTo(self.contentView);
|
}];
|
// UIViewContentModeScaleToFill,
|
// UIViewContentModeScaleAspectFit, // contents scaled to fit with fixed aspect. remainder is transparent
|
// UIViewContentModeScaleAspectFill, // contents scaled to fill with fixed aspect. some portion of content may be clipped.
|
// UIViewContentModeRedraw, // redraw on bounds change (calls -setNeedsDisplay)
|
// UIViewContentModeCenter,
|
imageV.contentMode = UIViewContentModeScaleAspectFill;
|
imageV.backgroundColor = [UIColor blackColor];
|
UIButton *playBtn = [UIButton z_bgImageButton:[UIImage imageNamed:@"details_play"]];
|
[playBtn addTarget:self action:@selector(playViedo) forControlEvents:UIControlEventTouchUpInside];
|
[self.contentView addSubview:playBtn];
|
[playBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.center.equalTo(self.contentView);
|
make.size.mas_equalTo(CGSizeMake(30, 30));
|
}];
|
|
self.imageV = imageV;
|
self.playBtn = playBtn;
|
}
|
- (void)playViedo {
|
if (self.PlayVideoBlock) {
|
self.PlayVideoBlock();
|
}
|
}
|
- (void)setVideoUrl:(NSString *)videoUrl {
|
_videoUrl = videoUrl;
|
NSString *imageStr = [videoUrl stringByReplacingOccurrencesOfString:@".mp4" withString:@"_image.png"];
|
[self.imageV sd_setImageWithURL:[NSURL URLWithString:imageStr] placeholderImage:[UIImage imageNamed:@""]];
|
}
|
@end
|