Browse Source

节拍器功能开发

Steven 2 years ago
parent
commit
c5446c0dfd

BIN
KulexiuForStudent/KulexiuForStudent.xcworkspace/xcuserdata/wangzhi.xcuserdatad/UserInterfaceState.xcuserstate


+ 25 - 11
KulexiuForStudent/KulexiuForStudent/Module/Live/View/SeatContentView.m

@@ -11,6 +11,8 @@
 
 @interface SeatMemberView : UIView
 
+@property (nonatomic, strong) UIImageView *userAvatar;
+
 @property (nonatomic, strong) NSString *userId;
 
 @property (nonatomic, strong) NSString *userName;
@@ -36,12 +38,12 @@
     self.backgroundColor = [UIColor clearColor];
     
     if ([self.userId isEqualToString:UserDefault(UIDKey)]) { // 自己
-        UIImageView *bgImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"seat_mine"]];
-        [self addSubview:bgImage];
-        [bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
+        [self.userAvatar sd_setImageWithURL:[NSURL URLWithString:[UserDefault(AvatarUrlKey) getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
+        [self addSubview:self.userAvatar];
+        [self.userAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
             make.centerX.mas_equalTo(self.mas_centerX);
             make.top.mas_equalTo(self.mas_top);
-            make.width.height.mas_equalTo(54);
+            make.width.height.mas_equalTo(46);
         }];
         UIView *bgView = [[UIView alloc] initWithFrame:CGRectZero];
         bgView.layer.cornerRadius = 7.0f;
@@ -52,15 +54,15 @@
             make.centerX.mas_equalTo(self.mas_centerX);
             make.left.mas_greaterThanOrEqualTo(self.mas_left).offset(5);
             make.height.mas_equalTo(15);
-            make.top.mas_equalTo(bgImage.mas_bottom).offset(-2);
+            make.top.mas_equalTo(self.userAvatar.mas_bottom).offset(2);
         }];
         
         [bgView addSubview:self.nameLabel];
         [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
             make.centerX.mas_equalTo(bgView.mas_centerX);
             make.centerY.mas_equalTo(bgView.mas_centerY);
-            make.left.mas_equalTo(bgView.mas_left).offset(6);
-            make.right.mas_equalTo(bgView.mas_right).offset(-6);
+            make.left.mas_equalTo(bgView.mas_left).offset(3);
+            make.right.mas_equalTo(bgView.mas_right).offset(-3);
         }];
         
         
@@ -69,9 +71,10 @@
         
     }
     else { // 其他人
-        UIImageView *bgImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"seat_other"]];
-        [self addSubview:bgImage];
-        [bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
+        [self.userAvatar setImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
+
+        [self addSubview:self.userAvatar];
+        [self.userAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
             make.centerX.mas_equalTo(self.mas_centerX);
             make.top.mas_equalTo(self.mas_top).offset(4);
             make.width.height.mas_equalTo(46);
@@ -80,7 +83,7 @@
         [self addSubview:self.nameLabel];
         [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
             make.left.right.mas_equalTo(self);
-            make.top.mas_equalTo(bgImage.mas_bottom).offset(2);
+            make.top.mas_equalTo(self.userAvatar.mas_bottom).offset(2);
             make.height.mas_equalTo(13);
         }];
         [self queryUserInfoWithUserId:self.userId];
@@ -97,12 +100,23 @@
     return _nameLabel;
 }
 
+- (UIImageView *)userAvatar {
+    if (!_userAvatar) {
+        _userAvatar = [[UIImageView alloc] init];
+        _userAvatar.contentMode = UIViewContentModeScaleAspectFill;
+        _userAvatar.layer.cornerRadius = 23.0f;
+        [_userAvatar.layer setMasksToBounds:YES];
+    }
+    return _userAvatar;
+}
+
 - (void)queryUserInfoWithUserId:(NSString *)userId {
     [KSNetworkingManager imUserFriendQueryDetail:KS_POST userId:userId success:^(NSDictionary * _Nonnull dic) {
         if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
             NSDictionary *result = [dic dictionaryValueForKey:@"data"];
             if (self) {
                 self.nameLabel.text = [result stringValueForKey:@"friendNickname"];
+                [self.userAvatar sd_setImageWithURL:[NSURL URLWithString:[[result stringValueForKey:@"friendAvatar"] getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
             }
             else {
                 NSLog(@"-delloc------");

+ 10 - 0
KulexiuForStudent/KulexiuForStudent/Module/Widget/Controller/WidgetViewController.m

@@ -48,6 +48,8 @@
 
 @property (nonatomic, assign) NSInteger totalNoCount;
 
+@property (nonatomic, assign) float playVolume;
+
 @end
 
 @implementation WidgetViewController
@@ -62,9 +64,11 @@
 
 - (void)setDefaultConfig {
     self.speed = 90;
+    self.playVolume = 1.0f;
     [self updateSpeedUI];
     self.metronomeType = KSMetronomeType4V4;
     [self changeBeat];
+    self.functionView.volumeRate = 1.0f;
 }
 
 
@@ -109,6 +113,12 @@
 
 
 #pragma mark --- delegate
+- (void)volumeChange:(float)volume {
+    self.playVolume = volume;
+    [self.audioPlayDONG setVolume:volume];
+    [self.audioPlayDI setVolume:volume];
+}
+
 - (void)clickChangeBeat {
     // 显示节拍选择弹窗
     MJWeakSelf;

+ 3 - 0
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/WidgetBottomButtonView.xib

@@ -53,6 +53,9 @@
             <nil key="simulatedTopBarMetrics"/>
             <nil key="simulatedBottomBarMetrics"/>
             <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
+            <connections>
+                <outlet property="actionButton" destination="dUf-b4-rpL" id="RBy-oS-v2K"/>
+            </connections>
             <point key="canvasLocation" x="131.8840579710145" y="-159.04017857142856"/>
         </view>
     </objects>

+ 2 - 0
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/WidgetFunctionView.h

@@ -14,6 +14,8 @@
 - (void)clickChangeSpeed:(int)speed;
 
 - (void)clickChangeBeat;
+// 播放音量调整
+- (void)volumeChange:(float)volume;
 
 @end
 

+ 11 - 0
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/WidgetFunctionView.m

@@ -31,6 +31,12 @@
     WidgetFunctionView *view = [[[NSBundle mainBundle] loadNibNamed:@"WidgetFunctionView" owner:nil options:nil] firstObject];
     return view;
 }
+- (IBAction)changeVolumeAction:(UISlider *)sender {
+    self.volumeRate = sender.value;
+    if (self.delegate && [self.delegate respondsToSelector:@selector(volumeChange:)]) {
+        [self.delegate volumeChange:sender.value];
+    }
+}
 
 - (IBAction)changeBeatAction:(id)sender {
     if (self.delegate && [self.delegate respondsToSelector:@selector(clickChangeBeat)]) {
@@ -112,6 +118,11 @@
             break;
     }
 }
+
+- (void)setVolumeRate:(CGFloat)volumeRate {
+    _volumeRate = volumeRate;
+    self.volumeSlider.value = volumeRate;
+}
 /*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.

+ 3 - 0
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/WidgetFunctionView.xib

@@ -58,6 +58,9 @@
                     <color key="minimumTrackTintColor" red="0.1764705882352941" green="0.7803921568627451" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                     <color key="maximumTrackTintColor" red="0.87450980392156863" green="0.87450980392156863" blue="0.87450980392156863" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                     <color key="thumbTintColor" red="0.1764705882" green="0.78039215689999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                    <connections>
+                        <action selector="changeVolumeAction:" destination="iN0-l3-epB" eventType="valueChanged" id="bW8-7J-Cqc"/>
+                    </connections>
                 </slider>
             </subviews>
             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>