萤石云 iOSSDK,移植跨平台相关工程
Davin
2023-06-25 dd29df2e08ac87c878e26513f1b5ae06eae7a6d9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//
//  HDLEZVideoQualityBoxView.m
//  EZSDK
//
//  Created by Davin on 2023/6/25.
//
 
#import "HDLEZVideoQualityBoxView.h"
 
#define radiusValue 8.
#define arrowWidth 8.
 
@interface HDLEZVideoQualityBoxView ()
 
@property (nonatomic, strong) UIButton *smoothBtn;
@property (nonatomic, strong) UIButton *balanceBtn;
@property (nonatomic, strong) UIButton *hdFullBtn;
 
@property (nonatomic, copy) void(^qualityOperation)(HDLEZVideoFullSceneOperation operationType);
 
@end
 
@implementation HDLEZVideoQualityBoxView
 
- (instancetype)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        [self createSubviews];
    }
    return self;
}
 
 
- (void)createSubviews {
    self.backgroundColor = [UIColor clearColor];
    [self addSubview:self.smoothBtn];
    [self addSubview:self.balanceBtn];
    [self addSubview:self.hdFullBtn];
    
    [self.smoothBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top);
        make.left.mas_equalTo(self.mas_left);
        make.right.mas_equalTo(self.mas_right);
    }];
    
    [self.balanceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.smoothBtn.mas_bottom);
        make.left.mas_equalTo(self.mas_left);
        make.right.mas_equalTo(self.mas_right);
        make.height.mas_equalTo(self.smoothBtn.mas_height);
    }];
    
    [self.hdFullBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.balanceBtn.mas_bottom);
        make.left.mas_equalTo(self.mas_left);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-arrowWidth);
        make.right.mas_equalTo(self.mas_right);
        make.height.mas_equalTo(self.smoothBtn.mas_height);
    }];
 
    [self.smoothBtn addTarget:self action:@selector(selectedSmooth) forControlEvents:UIControlEventTouchUpInside];
    [self.balanceBtn addTarget:self action:@selector(selectedBalance) forControlEvents:UIControlEventTouchUpInside];
    [self.hdFullBtn addTarget:self action:@selector(selectedHdFull) forControlEvents:UIControlEventTouchUpInside];
}
 
- (void)drawRect:(CGRect)rect{
    CGFloat w = rect.size.width;
    CGFloat h = rect.size.height;
    UIBezierPath *path = [UIBezierPath bezierPath];
    UIColor *bgColor;
    [path moveToPoint:CGPointMake(0, h - radiusValue - arrowWidth)];
    [path addArcWithCenter:CGPointMake(radiusValue, h - radiusValue - arrowWidth)
                    radius:radiusValue
                startAngle:M_PI
                  endAngle:M_PI_2
                 clockwise:NO];
    
    [path addLineToPoint:CGPointMake(w/2. - arrowWidth, h - arrowWidth)];
    [path addLineToPoint:CGPointMake(w/2., h)];
    [path addLineToPoint:CGPointMake(w/2. + arrowWidth, h - arrowWidth)];
    
    [path addLineToPoint:CGPointMake(w - radiusValue, h - arrowWidth)];
    [path addArcWithCenter:CGPointMake(w - radiusValue, h - radiusValue - arrowWidth)
                    radius:radiusValue
                startAngle:M_PI_2
                  endAngle:0
                 clockwise:NO];
    [path addLineToPoint:CGPointMake(w, radiusValue)];
    [path addArcWithCenter:CGPointMake(w - radiusValue, radiusValue)
                    radius:radiusValue
                startAngle:0
                  endAngle:-M_PI_2
                 clockwise:NO];
    [path addLineToPoint:CGPointMake(radiusValue, 0)];
    [path addArcWithCenter:CGPointMake(radiusValue, radiusValue)
                    radius:radiusValue
                startAngle:-M_PI_2
                  endAngle:-M_PI
                 clockwise:NO];
    [path addLineToPoint:CGPointMake(0, h - radiusValue - arrowWidth)];
    
    
    bgColor = HDLEZHEXCOLOR(0x292929, 1.);
    [bgColor setFill];
    [path fill];
    
    [path setLineWidth:0.5];
    [HDLEZHEXCOLOR(0x292929, 1.) setStroke];
    [path stroke];
    
    [path closePath];
}
 
#pragma mark - PublishMethod
- (void)videoQualityChange:(void(^)(HDLEZVideoFullSceneOperation operationType))qualityBlock {
    self.qualityOperation = qualityBlock;
}
 
#pragma mark - PrivateMethod
- (void)selectedSmooth {
    if (self.qualityOperation) {
        self.qualityOperation(HDLEZVideoFullSceneOperationOfSmooth);
    }
}
 
- (void)selectedBalance {
    if (self.qualityOperation) {
        self.qualityOperation(HDLEZVideoFullSceneOperationOfBalance);
    }
}
 
- (void)selectedHdFull {
    if (self.qualityOperation) {
        self.qualityOperation(HDLEZVideoFullSceneOperationOfHDFull);
    }
}
 
#pragma mark - Getter
- (UIButton *)smoothBtn {
    if (!_smoothBtn) {
        _smoothBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_smoothBtn setImage:[UIImage imageNamed:@"hdl_ez_cat_eyes_full_smooth"] forState:UIControlStateNormal];
    }
    return _smoothBtn;
}
 
- (UIButton *)balanceBtn {
    if (!_balanceBtn) {
        _balanceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_balanceBtn setImage:[UIImage imageNamed:@"hdl_ez_cat_eyes_full_balance"] forState:UIControlStateNormal];
 
    }
    return _balanceBtn;
}
 
- (UIButton *)hdFullBtn {
    if (!_hdFullBtn) {
        _hdFullBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_hdFullBtn setImage:[UIImage imageNamed:@"hdl_ez_cat_eyes_full_hd_full"] forState:UIControlStateNormal];
 
    }
    return _hdFullBtn;
}
 
@end