PlayerFunctionView.m 2.41 KB
//
//  PlayerFunctionView.m
//  CNLiveBKLiveSDKDemo
//
//  Created by iOS on 17/4/5.
//  Copyright © 2017年 zhulin. All rights reserved.
//

#import "PlayerFunctionView.h"
#import "UIView+Extension.h"

@implementation PlayerFunctionView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
        
        [self addSubview:self.playOrPauseBtn];
        [self addSubview:self.currentTimeLabel];
        [self addSubview:self.timeSlide];
        [self addSubview:self.durationLabel];
        
    }
    return self;
}

- (UIButton *)playOrPauseBtn
{
    if (!_playOrPauseBtn) {
        _playOrPauseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _playOrPauseBtn.frame = CGRectMake(15, 10, 40, 40);
        [_playOrPauseBtn setImage:[UIImage imageNamed:@"start"] forState:UIControlStateNormal];
        [_playOrPauseBtn setImage:[UIImage imageNamed:@"suspend"] forState:UIControlStateSelected];
    }
    return _playOrPauseBtn;
}

- (UISlider *)timeSlide
{
    if (!_timeSlide) {
        _timeSlide = [[UISlider alloc] initWithFrame:CGRectMake(130, 15, self.frame.size.width-130-80, 30)];
        [_timeSlide setThumbImage:[UIImage imageNamed:@"btn_dot"] forState:UIControlStateNormal];
        [_timeSlide setMinimumTrackTintColor:[UIColor redColor]];
        [_timeSlide setMaximumTrackTintColor:[UIColor whiteColor]];
    }
    return _timeSlide;
}

- (UILabel *)currentTimeLabel
{
    if (!_currentTimeLabel) {
        _currentTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(65, 5, 60, 50)];
        _currentTimeLabel.textColor = [UIColor whiteColor];
        _currentTimeLabel.font = [UIFont systemFontOfSize:13];
        [_currentTimeLabel setText:[NSString stringWithFormat:@"00:00:00"]];
    }
    return _currentTimeLabel;
}

- (UILabel *)durationLabel
{
    if (!_durationLabel) {
        _durationLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width-60-10, 5, 60, 50)];
        _durationLabel.textColor = [UIColor whiteColor];
        _durationLabel.font = [UIFont systemFontOfSize:13];
        [_durationLabel setText:[NSString stringWithFormat:@"00:00:00"]];
    }
    return _durationLabel;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end