Bladeren bron

1.底部按钮UI

huangxiaodong 10 maanden geleden
bovenliggende
commit
bd2b510f60

+ 20 - 0
创维盒子/双子星云手机.xcodeproj/project.pbxproj

@@ -432,6 +432,10 @@
 		6B3E7A6F2C89479000B032C4 /* webRtcPlayerViewController+AdjustBtnFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3E7A6D2C89478A00B032C4 /* webRtcPlayerViewController+AdjustBtnFrame.m */; };
 		6B3E7A702C89479300B032C4 /* webRtcPlayerViewController+AdjustBtnFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3E7A6C2C89478A00B032C4 /* webRtcPlayerViewController+AdjustBtnFrame.h */; };
 		6B3E7A712C89479300B032C4 /* webRtcPlayerViewController+AdjustBtnFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3E7A6D2C89478A00B032C4 /* webRtcPlayerViewController+AdjustBtnFrame.m */; };
+		6B3E7A752C8960CA00B032C4 /* webRtcPlayerBottomContrView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3E7A732C8960CA00B032C4 /* webRtcPlayerBottomContrView.h */; };
+		6B3E7A762C8960CA00B032C4 /* webRtcPlayerBottomContrView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3E7A742C8960CA00B032C4 /* webRtcPlayerBottomContrView.m */; };
+		6B3E7A772C8960CA00B032C4 /* webRtcPlayerBottomContrView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3E7A732C8960CA00B032C4 /* webRtcPlayerBottomContrView.h */; };
+		6B3E7A782C8960CA00B032C4 /* webRtcPlayerBottomContrView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3E7A742C8960CA00B032C4 /* webRtcPlayerBottomContrView.m */; };
 		6B3F96342AD2A15A008E349E /* netWorkManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3F96322AD2A15A008E349E /* netWorkManager.h */; };
 		6B3F96352AD2A15A008E349E /* netWorkManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3F96332AD2A15A008E349E /* netWorkManager.m */; };
 		6B3F963A2AD2AD0B008E349E /* newWorkInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3F96392AD2AD0B008E349E /* newWorkInterface.h */; };
@@ -1768,6 +1772,8 @@
 		6B3AD6892BF4AE630096D6B7 /* backupsOptionViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = backupsOptionViewController.m; sourceTree = "<group>"; };
 		6B3E7A6C2C89478A00B032C4 /* webRtcPlayerViewController+AdjustBtnFrame.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "webRtcPlayerViewController+AdjustBtnFrame.h"; sourceTree = "<group>"; };
 		6B3E7A6D2C89478A00B032C4 /* webRtcPlayerViewController+AdjustBtnFrame.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "webRtcPlayerViewController+AdjustBtnFrame.m"; sourceTree = "<group>"; };
+		6B3E7A732C8960CA00B032C4 /* webRtcPlayerBottomContrView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = webRtcPlayerBottomContrView.h; sourceTree = "<group>"; };
+		6B3E7A742C8960CA00B032C4 /* webRtcPlayerBottomContrView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = webRtcPlayerBottomContrView.m; sourceTree = "<group>"; };
 		6B3F96322AD2A15A008E349E /* netWorkManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = netWorkManager.h; sourceTree = "<group>"; };
 		6B3F96332AD2A15A008E349E /* netWorkManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = netWorkManager.m; sourceTree = "<group>"; };
 		6B3F96392AD2AD0B008E349E /* newWorkInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = newWorkInterface.h; sourceTree = "<group>"; };
@@ -3018,6 +3024,15 @@
 			path = view;
 			sourceTree = "<group>";
 		};
+		6B3E7A722C89609E00B032C4 /* view */ = {
+			isa = PBXGroup;
+			children = (
+				6B3E7A732C8960CA00B032C4 /* webRtcPlayerBottomContrView.h */,
+				6B3E7A742C8960CA00B032C4 /* webRtcPlayerBottomContrView.m */,
+			);
+			path = view;
+			sourceTree = "<group>";
+		};
 		6B3F96312AD2A0FA008E349E /* netWork */ = {
 			isa = PBXGroup;
 			children = (
@@ -3343,6 +3358,7 @@
 		6B8676802C855ECC00F81DFC /* webRtc */ = {
 			isa = PBXGroup;
 			children = (
+				6B3E7A722C89609E00B032C4 /* view */,
 				6B8676942C8596F800F81DFC /* model */,
 				6B8676812C855EDF00F81DFC /* WebRTC.framework */,
 				6B86768E2C858CB300F81DFC /* webRtcPlayerViewController.h */,
@@ -3991,6 +4007,7 @@
 				6B45C50C2B5FA80E007E6911 /* diskListBgView.h in Headers */,
 				6B2170912B15BAE700656670 /* privacyModeViewController.h in Headers */,
 				6BF558B42C44F11C00701854 /* previewAudioPortraitTopMoreView.h in Headers */,
+				6B3E7A752C8960CA00B032C4 /* webRtcPlayerBottomContrView.h in Headers */,
 				6B2C1E5C2C070ADE00FDCF82 /* ZFFloatView.h in Headers */,
 				6B1FBD3A2B467A8000926382 /* backupsFilerecordTableView.h in Headers */,
 				6B7DDF262C421DA900EBDFDD /* previewVideoLandscapeTopMoreView.h in Headers */,
@@ -4271,6 +4288,7 @@
 				6BD506BE2B9576A4006E7CB0 /* diskListBgView.h in Headers */,
 				6BD506BF2B9576A4006E7CB0 /* privacyModeViewController.h in Headers */,
 				6BF558B62C44F11C00701854 /* previewAudioPortraitTopMoreView.h in Headers */,
+				6B3E7A772C8960CA00B032C4 /* webRtcPlayerBottomContrView.h in Headers */,
 				6B2C1E5D2C070ADE00FDCF82 /* ZFFloatView.h in Headers */,
 				6BD506C02B9576A4006E7CB0 /* backupsFilerecordTableView.h in Headers */,
 				6B7DDF282C421DA900EBDFDD /* previewVideoLandscapeTopMoreView.h in Headers */,
@@ -4991,6 +5009,7 @@
 				6B2C1E512C070ADE00FDCF82 /* ZFUtilities.m in Sources */,
 				6BD5075C2B9576A4006E7CB0 /* BGTool.m in Sources */,
 				6B3E7A712C89479300B032C4 /* webRtcPlayerViewController+AdjustBtnFrame.m in Sources */,
+				6B3E7A782C8960CA00B032C4 /* webRtcPlayerBottomContrView.m in Sources */,
 				6B34DC682BF1FFB1002DD1EF /* imageCollectionViewCell.m in Sources */,
 				6BD5075D2B9576A4006E7CB0 /* JSONModelClassProperty.m in Sources */,
 				6BD5075E2B9576A4006E7CB0 /* uploadFileManager.m in Sources */,
@@ -5353,6 +5372,7 @@
 				6B2C1E502C070ADE00FDCF82 /* ZFUtilities.m in Sources */,
 				A08A94FE27E9A4E400C544BB /* BGTool.m in Sources */,
 				6B3E7A6F2C89479000B032C4 /* webRtcPlayerViewController+AdjustBtnFrame.m in Sources */,
+				6B3E7A762C8960CA00B032C4 /* webRtcPlayerBottomContrView.m in Sources */,
 				6B34DC662BF1FFB1002DD1EF /* imageCollectionViewCell.m in Sources */,
 				183AE6072A89CE3C00B11CB0 /* JSONModelClassProperty.m in Sources */,
 				6B0582862B0457C400D37290 /* uploadFileManager.m in Sources */,

+ 18 - 0
创维盒子/双子星云手机/webRtc/view/webRtcPlayerBottomContrView.h

@@ -0,0 +1,18 @@
+//
+//  webRtcPlayerBottomContrView.h
+//  双子星云手机
+//
+//  Created by xd h on 2024/9/5.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface webRtcPlayerBottomContrView : UIView
+@property (nonatomic,copy) void (^didClickButtonFun)(NSInteger tag);
+
+- (void)updateFrameFun;
+@end
+
+NS_ASSUME_NONNULL_END

+ 150 - 0
创维盒子/双子星云手机/webRtc/view/webRtcPlayerBottomContrView.m

@@ -0,0 +1,150 @@
+//
+//  webRtcPlayerBottomContrView.m
+//  双子星云手机
+//
+//  Created by xd h on 2024/9/5.
+//
+
+#import "webRtcPlayerBottomContrView.h"
+
+@interface webRtcPlayerBottomContrView ()
+{
+    UIButton *mueBtn;
+    UIButton *homeBtn;
+    UIButton *backBtn;
+    
+    UIButton *showHomeBtn;
+}
+@end
+
+@implementation webRtcPlayerBottomContrView
+
+- (id)initWithFrame:(CGRect)frame{
+    self = [super initWithFrame:frame];
+    
+    if (self){
+        [self setBackgroundColor:[UIColor blackColor]];
+        [self initAddSubViewForBottomContrView];
+    }
+    
+    return self;
+}
+
+- (void)initAddSubViewForBottomContrView{
+    /*第一个app菜单*/
+    UIImage  *mueBtnImage = [UIImage imageNamed:@"houtai_icon"];
+    mueBtn = [[UIButton alloc] init];
+    mueBtn.tag = 1;
+    [mueBtn setBackgroundColor:[UIColor clearColor]];
+    [mueBtn addTarget:self
+               action:@selector(didClickButtonFun:)
+     forControlEvents:(UIControlEventTouchUpInside)];
+    [mueBtn setImage:mueBtnImage forState:(UIControlStateNormal)];
+    [mueBtn setImageEdgeInsets:(UIEdgeInsetsMake(6.f, 6.f, 6.f, 6.f))];
+    [self addSubview:mueBtn];
+    
+    /*第二个home键*/
+    UIImage  *homeBtnImage = [UIImage imageNamed:@"home_icon"];
+    homeBtn = [[UIButton alloc] init];
+    homeBtn.tag = 2;
+    [homeBtn setBackgroundColor:[UIColor clearColor]];
+    [homeBtn addTarget:self
+                action:@selector(didClickButtonFun:)
+      forControlEvents:(UIControlEventTouchUpInside)];
+    [homeBtn setImage:homeBtnImage forState:(UIControlStateNormal)];
+    [homeBtn setImageEdgeInsets:(UIEdgeInsetsMake(6.f, 6.f, 6.f, 6.f))];
+    [self addSubview:homeBtn];
+    
+    /*第三个返回键*/
+    UIImage  *backBtnImage = [UIImage imageNamed:@"fanhui_you_icon"];
+    backBtn = [[UIButton alloc] init];
+    backBtn.tag = 3;
+    [backBtn setBackgroundColor:[UIColor clearColor]];
+    [backBtn addTarget:self
+                action:@selector(didClickButtonFun:)
+      forControlEvents:(UIControlEventTouchUpInside)];
+    [backBtn setImage:backBtnImage forState:(UIControlStateNormal)];
+    [backBtn setImageEdgeInsets:(UIEdgeInsetsMake(6.f, 6.f, 6.f, 6.f))];
+    [self addSubview:backBtn];
+    //测试说图片方向反了
+    //backBtn.imageView.transform = CGAffineTransformMakeRotation(M_PI);
+    
+    /*第四个隐藏显示键*/
+    UIImage  *showBtnImage = [UIImage imageNamed:@"showOrhide_home_icon"];
+    showHomeBtn = [[UIButton alloc] init];
+    showHomeBtn.tag = 4;
+    [showHomeBtn setBackgroundColor:[UIColor clearColor]];
+    [showHomeBtn addTarget:self action:@selector(didClickButtonFun:) forControlEvents:(UIControlEventTouchUpInside)];
+    [showHomeBtn setImage:showBtnImage forState:(UIControlStateNormal)];
+    [showHomeBtn setImageEdgeInsets:(UIEdgeInsetsMake(6.f, 6.f, 6.f, 6.f))];
+    [self addSubview:showHomeBtn];
+}
+
+#pragma mark 更新按钮区域
+- (void)updateFrameFun
+{
+    [mueBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.right.mas_equalTo(-80.f);
+        make.width.and.height.mas_equalTo(40.f);
+        make.top.mas_equalTo(0);
+        
+    }];
+
+    [homeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.centerX.equalTo(self.mas_centerX);
+        make.width.and.height.mas_equalTo(40.f);
+        make.top.mas_equalTo(0);
+    }];
+
+    UIImage  *backBtnImage = [UIImage imageNamed:@"fanhui_you_icon"];
+//        UIImage  *backBtnImage = [UIImage imageNamed:@"fanhui_icon"];
+    [backBtn setImage:backBtnImage forState:(UIControlStateNormal)];
+    [backBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(80.f);
+        make.width.and.height.mas_equalTo(40.f);
+        make.top.mas_equalTo(0);
+    }];
+    
+    [showHomeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.right.mas_equalTo(-20.f);
+        make.width.and.height.mas_equalTo(40.f);
+        make.top.mas_equalTo(0);
+    }];
+    
+    //[self getPlayerBottomNavShowOrHidefun];
+}
+
+- (void)didClickButtonFun:(UIButton*)but
+{
+    NSInteger tag = but.tag;
+    if(_didClickButtonFun){
+        _didClickButtonFun(tag);
+    }
+    
+    if(tag == 4){
+        [self showOrHideHomeButtomFun:but];
+    }
+}
+
+- (void)showOrHideHomeButtomFun:(UIButton*)but{
+    but.selected = !but.selected;
+    
+    if(but.selected){
+        but.imageView.transform = CGAffineTransformMakeRotation(M_PI);
+    }
+    else{
+        but.imageView.transform = CGAffineTransformMakeRotation(0);
+    }
+    
+    [self setShowOrHideBottomButtonsFunBy:but.selected];
+}
+
+- (void)setShowOrHideBottomButtonsFunBy:(BOOL)isHide
+{
+    mainBlock(^{
+        self->mueBtn.hidden = isHide;
+        self->homeBtn.hidden = isHide;
+        self->backBtn.hidden = isHide;
+    });
+}
+@end

+ 21 - 45
创维盒子/双子星云手机/webRtc/webRtcPlayerViewController.m

@@ -7,12 +7,13 @@
 
 #import "webRtcPlayerViewController.h"
 #import "webRtcPlayerViewController+AdjustBtnFrame.h"
+#import "webRtcPlayerBottomContrView.h"
 
 @interface webRtcPlayerViewController ()<MediaStreamClientEventsDelegate>
 
 @property (nonatomic, copy)   NSTimer      *playerSecondTimer; // 定时器-控制按钮
 @property (nonatomic, assign) NSInteger          concentTime; // 拉流数据 渲染更新时间戳 /**30s后 渲染时间戳无更新 自动断开链接*/
-
+@property(nonatomic,strong)webRtcPlayerBottomContrView    *bottomContrView;//底部按钮 选项 home 返回
 @end
 
 @implementation webRtcPlayerViewController
@@ -103,17 +104,21 @@
     
     HLog(@"result:%ld",result)
     
+    [self initBaseUIFun];
+    [self setTimerCountDown];
+    
     CGFloat curRate = 1080.0/1920.0;
     [self setPoMas_makeWithImageRate:curRate];
     [self showNewIndicatorWithCanBack:YES canTouch:NO];
     
-    [self initBaseUIFun];
-    [self setTimerCountDown];
 }
 
 #pragma mark 初始化其他UI
 - (void)initBaseUIFun
 {
+    _bottomContrView = [[webRtcPlayerBottomContrView alloc] init];
+    [self.view addSubview:_bottomContrView];
+    
     /*控制按钮*/
     UIImage  *driftBtnImage = [UIImage imageNamed:@"you_icon"];
     controlBtn = [[UIButton alloc] init];
@@ -249,48 +254,19 @@
     }];
     
     
-//    [bottomContrView setHidden:NO];
-//    [bottomContrView mas_remakeConstraints:^(MASConstraintMaker *make) {
-//        make.height.mas_equalTo(40.f);
-//        make.right.equalTo(touchCommondView.mas_right);
-//        if(fullScreenShow){
-//            make.bottom.mas_equalTo(0);
-//        }
-//        else{
-//            make.top.equalTo(touchCommondView.mas_bottom);
-//        }
-//        make.left.equalTo(touchCommondView.mas_left);
-//    }];
-//
-//    [mueBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
-//        make.right.mas_equalTo(-80.f);
-//        make.width.and.height.mas_equalTo(40.f);
-//        make.top.mas_equalTo(0);
-//        
-//    }];
-//
-//    [homeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
-//        make.centerX.equalTo(bottomContrView.mas_centerX);
-//        make.width.and.height.mas_equalTo(40.f);
-//        make.top.mas_equalTo(0);
-//    }];
-//
-//    UIImage  *backBtnImage = [UIImage imageNamed:@"fanhui_you_icon"];
-////        UIImage  *backBtnImage = [UIImage imageNamed:@"fanhui_icon"];
-//    [backBtn setImage:backBtnImage forState:(UIControlStateNormal)];
-//    [backBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
-//        make.left.mas_equalTo(80.f);
-//        make.width.and.height.mas_equalTo(40.f);
-//        make.top.mas_equalTo(0);
-//    }];
-//    
-//    [showHomeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
-//        make.right.mas_equalTo(-20.f);
-//        make.width.and.height.mas_equalTo(40.f);
-//        make.top.mas_equalTo(0);
-//    }];
-//    
-//    [self getPlayerBottomNavShowOrHidefun];
+    [_bottomContrView mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.height.mas_equalTo(40.f);
+        make.right.equalTo(_mediaStream.mas_right);
+        if(fullScreenShow){
+            make.bottom.mas_equalTo(0);
+        }
+        else{
+            make.top.equalTo(_mediaStream.mas_bottom);
+        }
+        make.left.equalTo(_mediaStream.mas_left);
+    }];
+
+    [_bottomContrView updateFrameFun];
 }
 
 /**