// // playerSetView.m // 双子星云手机 // // Created by xd h on 2024/6/24. // #import "playerSetView.h" #import "SYJUISwitch.h" @interface playerSetView () @property(nonatomic, strong)UIView* blackBgView; @property(nonatomic, strong)UIView *bg0View;//1.4.4 新加分辨率 @property(nonatomic, strong) UIButton *resolution720Button; @property(nonatomic, strong) UIButton *resolution1080Button; @property(nonatomic,strong) CAGradientLayer *glayer; @property(nonatomic, strong) UIView *bg1View; @property(nonatomic, strong) SYJUISwitch * bottomNavSwitch;//底部导航栏开关 @property(nonatomic, strong) SYJUISwitch * fullScreenSwitch;//全面屏开关 @property(nonatomic, strong) UIButton *TVButton; @property(nonatomic, strong) UILabel *TVShowLabel; @property(nonatomic, strong) UIButton *exitPhoneButton; @property(nonatomic, strong) UILabel *delayedLabel;//延时 @property(nonatomic, strong) UILabel *PacketLossLabel;//丢包 @property(nonatomic, strong) UILabel *speedLabel;//速度(带宽) @property(nonatomic, strong) UILabel *fpsLabel; @end @implementation playerSetView - (id)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneTvStatusFun:) name:getCouldPhoneTvStatusNotification object:nil]; [self drawAnyView]; return self; } - (void)drawAnyView{ //扩大金融云机范围按钮 UIButton *bigButton = [[UIButton alloc] init]; bigButton.tag = 1; [bigButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:bigButton]; //bigButton.backgroundColor = [UIColor greenColor]; [bigButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(0); make.right.mas_equalTo(0); make.left.mas_equalTo(0); make.bottom.mas_equalTo(0); }]; _blackBgView = [UIView new]; _blackBgView.layer.cornerRadius = 20; _blackBgView.backgroundColor = [UIColor hwColor:@"#202630"]; [self addSubview:_blackBgView]; [_blackBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(260 + 50);//(256); make.width.mas_equalTo(320);//(245); make.centerX.mas_equalTo(0.f); make.centerY.mas_equalTo(0.f); }]; /***************************顶部按钮显示*******************************************************/ CGFloat laberTop = 24.0; CGFloat laberW = 30.0; CGFloat laberH = 16.0; //延迟 // UILabel * delayedTipLabel = [[UILabel alloc] init]; // delayedTipLabel.font = [UIFont systemFontOfSize:12.0]; // delayedTipLabel.textColor = [UIColor whiteColor]; // delayedTipLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil); // [_blackBgView addSubview:delayedTipLabel]; // //delayedTipLabel.backgroundColor = [UIColor redColor]; // // [delayedTipLabel mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.mas_equalTo(15); // make.width.mas_equalTo(laberW); // make.height.mas_equalTo(laberH); // make.top.mas_equalTo(laberTop); // }]; CGFloat fontSize = 12.0; ///获取设备当前地区的代码和APP语言环境 NSString *languageCode = [NSLocale preferredLanguages][0]; BOOL isForeignType = NO; //目前支持 中文(简体 繁体) 英文 日语 if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound) { } else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound) { } else{ isForeignType = YES; fontSize = 10.5; } _delayedLabel = [[UILabel alloc] init]; _delayedLabel.font = [UIFont systemFontOfSize:fontSize]; //_delayedLabel.textColor = [UIColor whiteColor]; //_delayedLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil); [_blackBgView addSubview:_delayedLabel]; //_delayedLabel.backgroundColor = [UIColor redColor]; [_delayedLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); //make.width.mas_equalTo(laberW+5); make.height.mas_equalTo(laberH); make.top.mas_equalTo(laberTop); }]; //丢包 // UILabel * PacketLossTipLabel = [[UILabel alloc] init]; // PacketLossTipLabel.font = [UIFont systemFontOfSize:12.0]; // PacketLossTipLabel.textColor = [UIColor whiteColor]; // PacketLossTipLabel.text = NSLocalizedString(@"webrtc_msg_PacketLoss",nil); // [blackBgView addSubview:PacketLossTipLabel]; // //delayedTipLabel.backgroundColor = [UIColor redColor]; // // [PacketLossTipLabel mas_makeConstraints:^(MASConstraintMaker *make) { // make.centerX.mas_equalTo(- 1.5*laberW -10); // make.width.mas_equalTo(laberW); // make.height.mas_equalTo(laberH); // make.top.mas_equalTo(laberTop); // }]; // _PacketLossLabel = [[UILabel alloc] init]; _PacketLossLabel.font = [UIFont systemFontOfSize:fontSize]; _PacketLossLabel.textAlignment = NSTextAlignmentCenter; _PacketLossLabel.textColor = [UIColor whiteColor];//[UIColor hwColor:@"#FF2855"]; //_PacketLossLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil); [_blackBgView addSubview:_PacketLossLabel]; //_PacketLossLabel.backgroundColor = [UIColor redColor]; [_PacketLossLabel mas_makeConstraints:^(MASConstraintMaker *make) { //make.left.mas_equalTo(PacketLossTipLabel.mas_right).offset(0); make.centerX.mas_equalTo(self.mas_centerX); //make.width.mas_equalTo(laberW*3.0); make.height.mas_equalTo(laberH); make.top.mas_equalTo(laberTop); }]; //带宽 // UILabel * speedLossTipLabel = [[UILabel alloc] init]; // speedLossTipLabel.font = [UIFont systemFontOfSize:12.0]; // speedLossTipLabel.textColor = [UIColor whiteColor]; // speedLossTipLabel.text = NSLocalizedString(@"webrtc_msg_speed",nil); // [blackBgView addSubview:speedLossTipLabel]; // //speedLossTipLabel.backgroundColor = [UIColor redColor]; // // [speedLossTipLabel mas_makeConstraints:^(MASConstraintMaker *make) { // make.centerX.mas_equalTo(1.5*laberW -10); // make.width.mas_equalTo(laberW +10 ); // make.height.mas_equalTo(laberH); // make.top.mas_equalTo(laberTop); // }]; _speedLabel = [[UILabel alloc] init]; _speedLabel.font = [UIFont systemFontOfSize:fontSize]; _speedLabel.textColor = [UIColor whiteColor]; _speedLabel.textAlignment = NSTextAlignmentRight; //_speedLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil); [_blackBgView addSubview:_speedLabel]; //_speedLabel.backgroundColor = [UIColor redColor]; [_speedLabel mas_makeConstraints:^(MASConstraintMaker *make) { //make.centerX.mas_equalTo(1.5*laberW); //make.centerX.mas_equalTo(self.mas_centerX); make.right.mas_equalTo(-15); //make.width.mas_equalTo(laberW*3.0); make.height.mas_equalTo(laberH); make.top.mas_equalTo(laberTop); }]; //fps // UILabel * fpsTipLabel = [[UILabel alloc] init]; // fpsTipLabel.font = [UIFont systemFontOfSize:12.0]; // fpsTipLabel.textColor = [UIColor whiteColor]; // fpsTipLabel.text = @"FPS:"; // [blackBgView addSubview:fpsTipLabel]; // //speedLossTipLabel.backgroundColor = [UIColor redColor]; // // [fpsTipLabel mas_makeConstraints:^(MASConstraintMaker *make) { // make.right.mas_equalTo(- 15 - 0.5*laberW); // make.width.mas_equalTo(laberW); // make.height.mas_equalTo(laberH); // make.top.mas_equalTo(laberTop); // }]; //_fpsLabel = [[UILabel alloc] init]; // _fpsLabel.textAlignment = NSTextAlignmentRight; // _fpsLabel.font = [UIFont systemFontOfSize:12.0]; // _fpsLabel.textColor = [UIColor whiteColor]; // //_fpsLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil); // [_blackBgView addSubview:_fpsLabel]; // //_fpsLabel.backgroundColor = [UIColor redColor]; // // [_fpsLabel mas_makeConstraints:^(MASConstraintMaker *make) { // make.right.mas_equalTo(-15); // make.width.mas_equalTo(laberW*2); // make.height.mas_equalTo(laberH); // make.top.mas_equalTo(laberTop); // }]; [self setWebRctMsgBydelayed:0 withPacketLoss:0.0 withSpeed:@"-" withFPS:@"-"]; /***************************分辨率*******************************************************/ _bg0View = [UIView new]; _bg0View.layer.cornerRadius = 8; _bg0View.backgroundColor = [UIColor hwColor:@"#29313D"]; [_blackBgView addSubview:_bg0View]; [_bg0View mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(36); make.left.mas_equalTo(12); make.right.mas_equalTo(-12); //make.top.mas_equalTo(16.f); make.top.mas_equalTo(62.f); }]; //分辨率 UILabel *resolutionTipLabel = [[UILabel alloc] init]; resolutionTipLabel.text = NSLocalizedString(@"cloudPhone_player_set_resolution",nil); resolutionTipLabel.textColor = [UIColor whiteColor]; resolutionTipLabel.font = [UIFont systemFontOfSize:12.0]; [_bg0View addSubview:resolutionTipLabel]; [resolutionTipLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.top.equalTo(_bg0View.mas_top).offset(0); make.bottom.equalTo(_bg0View.mas_bottom).offset(0); }]; _resolution720Button = [[UIButton alloc] init]; _resolution720Button.layer.cornerRadius = 5; _resolution720Button.backgroundColor = [UIColor hwColor:@"#D8D8D8" alpha:0.09]; [_resolution720Button setTitle:@"720*1280" forState:UIControlStateNormal]; [_resolution720Button setTitleColor:[UIColor hwColor:@"#FFFFFF"] forState:UIControlStateNormal]; _resolution720Button.titleLabel.font = [UIFont systemFontOfSize:12.0]; _resolution720Button.layer.masksToBounds = YES; [_resolution720Button addTarget:self action:@selector(didClickResolution720ButFun) forControlEvents:UIControlEventTouchUpInside]; [_bg0View addSubview:_resolution720Button]; [_resolution720Button mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(80); make.width.mas_equalTo(93); make.height.mas_equalTo(26); make.centerY.mas_equalTo(0); }]; _resolution1080Button = [[UIButton alloc] init]; _resolution1080Button.layer.cornerRadius = 5; _resolution1080Button.backgroundColor = [UIColor hwColor:@"#D8D8D8" alpha:0.09]; [_resolution1080Button setTitle:@"1080*1920" forState:UIControlStateNormal]; [_resolution1080Button setTitleColor:[UIColor hwColor:@"#FFFFFF"] forState:UIControlStateNormal]; _resolution1080Button.titleLabel.font = [UIFont systemFontOfSize:12.0]; _resolution1080Button.layer.masksToBounds = YES; [_resolution1080Button addTarget:self action:@selector(didClickResolution1080ButFun) forControlEvents:UIControlEventTouchUpInside]; [_bg0View addSubview:_resolution1080Button]; [_resolution1080Button mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-12); make.width.mas_equalTo(93); make.height.mas_equalTo(26); make.centerY.mas_equalTo(0); }]; // gradient _glayer = [CAGradientLayer layer]; _glayer.frame = CGRectMake(0, 0, 93, 26); _glayer.startPoint = CGPointMake(0, 0.5); _glayer.endPoint = CGPointMake(0.97, 0.5); _glayer.colors = @[(__bridge id)[UIColor hwColor:@"#0CDEFD" alpha:1.0].CGColor, (__bridge id)[UIColor hwColor:@"#058DFB" alpha:1.0].CGColor]; _glayer.locations = @[@(0), @(1.0f)]; [self firstSetResolutionFun]; /***************************全面屏相关*******************************************************/ _bg1View = [UIView new]; // bg1View.layer.cornerRadius = 12; // bg1View.backgroundColor = [UIColor hwColor:@"#29313D"]; [_blackBgView addSubview:_bg1View]; [_bg1View mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(42); make.left.mas_equalTo(12); make.right.mas_equalTo(-12); make.top.mas_equalTo(112.f); //make.top.mas_equalTo(54.f); }]; UIView *bgBottomNavView = [UIView new]; bgBottomNavView.layer.cornerRadius = 8; bgBottomNavView.backgroundColor = [UIColor hwColor:@"#29313D"]; [_blackBgView addSubview:bgBottomNavView]; [bgBottomNavView mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.mas_equalTo(_bg1View.mas_bottom); make.left.mas_equalTo(12); make.right.equalTo(self.mas_centerX).offset(-6); //make.top.mas_equalTo(16.f); make.top.mas_equalTo(_bg1View.mas_top); }]; UILabel *navSwitchTipLabel = [[UILabel alloc] init]; navSwitchTipLabel.text = NSLocalizedString(@"cloudPhone_nav_show_tip",nil); //navSwitchTipLabel.textAlignment = NSTextAlignmentCenter; navSwitchTipLabel.textColor = [UIColor whiteColor]; navSwitchTipLabel.font = [UIFont systemFontOfSize:12.0]; [bgBottomNavView addSubview:navSwitchTipLabel]; [navSwitchTipLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.top.equalTo(bgBottomNavView.mas_top).offset(0); make.bottom.equalTo(bgBottomNavView.mas_bottom).offset(0); }]; //底部导航栏开关 _bottomNavSwitch = [[SYJUISwitch alloc] initWithFrame:CGRectMake(0, 0, 44, 22)]; _bottomNavSwitch.onTintColor = HW13B2EBColor; _bottomNavSwitch.offTintColor = [UIColor hwColor:@"#E3E8F1"]; [_bottomNavSwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:UIControlEventValueChanged]; [bgBottomNavView addSubview:_bottomNavSwitch]; [_bottomNavSwitch mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-15.f); make.centerY.mas_equalTo(0.f); make.width.mas_equalTo(44.f); make.height.mas_equalTo(22.f); }]; //全面屏开关 UIView *bgFullScreenView = [UIView new]; bgFullScreenView.layer.cornerRadius = 8; bgFullScreenView.backgroundColor = [UIColor hwColor:@"#29313D"]; [_blackBgView addSubview:bgFullScreenView]; [bgFullScreenView mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.mas_equalTo(_bg1View.mas_bottom); make.right.mas_equalTo(-12); make.left.equalTo(self.mas_centerX).offset(6); //make.top.mas_equalTo(16.f); make.top.mas_equalTo(_bg1View.mas_top); }]; UILabel *fullScreenTipLabel = [[UILabel alloc] init]; fullScreenTipLabel.text = NSLocalizedString(@"cloudPhone_fullScreen_show_tip",nil); //fullScreenTipLabel.textAlignment = NSTextAlignmentCenter; fullScreenTipLabel.textColor = [UIColor whiteColor]; fullScreenTipLabel.font = [UIFont systemFontOfSize:12.0]; [bgFullScreenView addSubview:fullScreenTipLabel]; [fullScreenTipLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.top.equalTo(bgFullScreenView.mas_top).offset(0); make.bottom.equalTo(bgFullScreenView.mas_bottom).offset(0); }]; _fullScreenSwitch = [[SYJUISwitch alloc] initWithFrame:CGRectMake(0, 0, 44, 22)]; _fullScreenSwitch.onTintColor = HW13B2EBColor; _fullScreenSwitch.offTintColor = [UIColor hwColor:@"#E3E8F1"]; [_fullScreenSwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:UIControlEventValueChanged]; [bgFullScreenView addSubview:_fullScreenSwitch]; [_fullScreenSwitch mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-15.f); make.centerY.mas_equalTo(0.f); make.width.mas_equalTo(44.f); make.height.mas_equalTo(22.f); }]; KWeakSelf dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf setAllSwitchFun]; }); /**********************************************************************************/ UIView *bg2View = [UIView new]; bg2View.layer.cornerRadius = 12; bg2View.backgroundColor = [UIColor hwColor:@"#29313D"]; [_blackBgView addSubview:bg2View]; [bg2View mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(72); make.left.mas_equalTo(15); make.right.mas_equalTo(-15); make.top.equalTo(_bg1View.mas_bottom).offset(12); //make.top.mas_equalTo(52); }]; NSArray *titleArr = @[NSLocalizedString(@"cloudPhone_set_screenshot_tip",nil), NSLocalizedString(@"my_set_no_TV_p2p",nil), //NSLocalizedString(@"my_set_no_close_TV_p2p",nil), NSLocalizedString(@"my_set_no_restart_phone",nil), //NSLocalizedString(@"cloudPhone_set_exit_tip",nil), ]; NSArray *imageArr = @[@"cloudPhone_set_screenshot", @"cloudPhone_set_TV", @"cloudPhone_set_restart", //@"cloudPhone_set_exit", ]; CGFloat butTopY = 15.0; CGFloat imageWH = 24.0; CGFloat butHeight = imageWH +20 +5; CGFloat butWidth = (320 -15*2)/3.0; //70.0; //CGFloat butWidth = (245 -12*2)/2.0; //70.0; CGFloat butSpace = 0.0; //(245 - butWidth*3)/3.0; for (int i=0; i= 100) { _delayedLabel.textColor = [UIColor hwColor:@"#FF2855"]; } else if (delayedMS >= 50){ _delayedLabel.textColor = [UIColor yellowColor]; } else{ _delayedLabel.textColor = [UIColor hwColor:@"22A082"]; } if(delayedMS >= 1000){ _delayedLabel.text = [[NSString alloc] initWithFormat:@"%lds",delayedMS/1000]; } else{ _delayedLabel.text = [[NSString alloc] initWithFormat:@"%ldms",delayedMS]; } NSString * delayedStr = @""; if(delayedMS >= 1000){ delayedStr = [[NSString alloc] initWithFormat:@"%lds",delayedMS/1000]; } else{ delayedStr = [[NSString alloc] initWithFormat:@"%ldms",delayedMS]; } NSString*leftStr = NSLocalizedString(@"webrtc_msg_delayed",nil); NSString *fullTitle = [[NSString alloc] initWithFormat:@"%@%@",leftStr,delayedStr]; NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:fullTitle]; NSRange leftRange = NSMakeRange([fullTitle rangeOfString:leftStr].location, [fullTitle rangeOfString:leftStr].length); [attrStr addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:leftRange]; _delayedLabel.attributedText = attrStr; NSString*LossleftStr = NSLocalizedString(@"webrtc_msg_PacketLoss",nil); NSString*LossRightStr = [[NSString alloc] initWithFormat:@"%.02f%%",PacketLoss]; NSString *LossfullTitle = [[NSString alloc] initWithFormat:@"%@%@",LossleftStr,LossRightStr]; NSMutableAttributedString *attrStr2 = [[NSMutableAttributedString alloc] initWithString:LossfullTitle]; NSRange rightRange = NSMakeRange([LossfullTitle rangeOfString:LossRightStr].location, LossRightStr.length); UIColor *rightColor = [UIColor hwColor:@"22A082"]; if(PacketLoss >= 5 && PacketLoss < 10){ rightColor = [UIColor yellowColor]; } else if(PacketLoss >= 10){ rightColor = [UIColor hwColor:@"#FF2855"]; } [attrStr2 addAttribute:NSForegroundColorAttributeName value:rightColor range:rightRange]; _PacketLossLabel.attributedText = attrStr2; _speedLabel.text = [[NSString alloc] initWithFormat:@"%@%@",NSLocalizedString(@"webrtc_msg_speed",nil),speedStr]; //_fpsLabel.text = [[NSString alloc] initWithFormat:@"FPS:%@",fpsStr]; } #pragma mark 设置分辨率 - (void)firstSetResolutionFun { NSInteger curResolution = [HWDataManager getIntegerWithKey:Const_cloudPhone_cur_resolution]; if(curResolution == 0 || curResolution == 1){ _resolution720Button.selected = YES; [_resolution720Button.layer insertSublayer:_glayer atIndex:0]; } else{ _resolution1080Button.selected = YES; [_resolution1080Button.layer insertSublayer:_glayer atIndex:0]; } } #pragma mark 是否要显示设置分辨率(全面屏要隐藏) - (void)handleResolutionUIFun { BOOL isHide = [HWDataManager getBoolWithKey:Consn_player_full_screen_show]; if (isHide) { [_blackBgView mas_updateConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(260);//(256); }]; _bg0View.hidden = YES; [_bg1View mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(62); }]; } else{ [_blackBgView mas_updateConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(260 + 50);//(256); }]; _bg0View.hidden = NO; [_bg1View mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(112); }]; } } #pragma mark 点击了分辨率720 - (void)didClickResolution720ButFun { if(_resolution720Button.selected){ return; } _resolution1080Button.selected = NO; _resolution720Button.selected = YES; [_resolution720Button.layer insertSublayer:_glayer atIndex:0]; if(_didClickButtonFun){ _didClickButtonFun(1); } [HWDataManager setIntegerWithKey:Const_cloudPhone_cur_resolution value:1]; } #pragma mark 点击了分辨率1080 - (void)didClickResolution1080ButFun { if(_resolution1080Button.selected){ return; } _resolution720Button.selected = NO; _resolution1080Button.selected = YES; [_resolution1080Button.layer insertSublayer:_glayer atIndex:0]; if(_didClickButtonFun){ _didClickButtonFun(2); } [HWDataManager setIntegerWithKey:Const_cloudPhone_cur_resolution value:2]; } @end