playerSetView.m 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. //
  2. // playerSetView.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/6/24.
  6. //
  7. #import "playerSetView.h"
  8. #import "SYJUISwitch.h"
  9. @interface playerSetView ()
  10. @property(nonatomic, strong)UIView* blackBgView;
  11. @property(nonatomic, strong)UIView *bg0View;//1.4.4 新加分辨率
  12. @property(nonatomic, strong) UIButton *resolution720Button;
  13. @property(nonatomic, strong) UIButton *resolution1080Button;
  14. @property(nonatomic,strong) CAGradientLayer *glayer;
  15. @property(nonatomic, strong) UIView *bg1View;
  16. @property(nonatomic, strong) SYJUISwitch * bottomNavSwitch;//底部导航栏开关
  17. @property(nonatomic, strong) SYJUISwitch * fullScreenSwitch;//全面屏开关
  18. @property(nonatomic, strong) UIButton *TVButton;
  19. @property(nonatomic, strong) UILabel *TVShowLabel;
  20. @property(nonatomic, strong) UIButton *exitPhoneButton;
  21. @property(nonatomic, strong) UILabel *delayedLabel;//延时
  22. @property(nonatomic, strong) UILabel *PacketLossLabel;//丢包
  23. @property(nonatomic, strong) UILabel *speedLabel;//速度(带宽)
  24. @property(nonatomic, strong) UILabel *fpsLabel;
  25. @end
  26. @implementation playerSetView
  27. - (id)initWithFrame:(CGRect)frame{
  28. self = [super initWithFrame:frame];
  29. self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
  30. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneTvStatusFun:) name:getCouldPhoneTvStatusNotification object:nil];
  31. [self drawAnyView];
  32. return self;
  33. }
  34. - (void)drawAnyView{
  35. //扩大金融云机范围按钮
  36. UIButton *bigButton = [[UIButton alloc] init];
  37. bigButton.tag = 1;
  38. [bigButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  39. [self addSubview:bigButton];
  40. //bigButton.backgroundColor = [UIColor greenColor];
  41. [bigButton mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.top.mas_equalTo(0);
  43. make.right.mas_equalTo(0);
  44. make.left.mas_equalTo(0);
  45. make.bottom.mas_equalTo(0);
  46. }];
  47. _blackBgView = [UIView new];
  48. _blackBgView.layer.cornerRadius = 20;
  49. _blackBgView.backgroundColor = [UIColor hwColor:@"#202630"];
  50. [self addSubview:_blackBgView];
  51. [_blackBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.height.mas_equalTo(260 + 50);//(256);
  53. make.width.mas_equalTo(320);//(245);
  54. make.centerX.mas_equalTo(0.f);
  55. make.centerY.mas_equalTo(0.f);
  56. }];
  57. /***************************顶部按钮显示*******************************************************/
  58. CGFloat laberTop = 24.0;
  59. CGFloat laberW = 30.0;
  60. CGFloat laberH = 16.0;
  61. //延迟
  62. UILabel * delayedTipLabel = [[UILabel alloc] init];
  63. delayedTipLabel.font = [UIFont systemFontOfSize:12.0];
  64. delayedTipLabel.textColor = [UIColor whiteColor];
  65. delayedTipLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
  66. [_blackBgView addSubview:delayedTipLabel];
  67. //delayedTipLabel.backgroundColor = [UIColor redColor];
  68. [delayedTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.left.mas_equalTo(15);
  70. make.width.mas_equalTo(laberW);
  71. make.height.mas_equalTo(laberH);
  72. make.top.mas_equalTo(laberTop);
  73. }];
  74. _delayedLabel = [[UILabel alloc] init];
  75. _delayedLabel.font = [UIFont systemFontOfSize:12.0];
  76. //_delayedLabel.textColor = [UIColor whiteColor];
  77. //_delayedLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
  78. [_blackBgView addSubview:_delayedLabel];
  79. //_delayedLabel.backgroundColor = [UIColor redColor];
  80. [_delayedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.left.mas_equalTo(delayedTipLabel.mas_right).offset(0);
  82. //make.width.mas_equalTo(laberW+5);
  83. make.height.mas_equalTo(laberH);
  84. make.top.mas_equalTo(laberTop);
  85. }];
  86. //丢包
  87. // UILabel * PacketLossTipLabel = [[UILabel alloc] init];
  88. // PacketLossTipLabel.font = [UIFont systemFontOfSize:12.0];
  89. // PacketLossTipLabel.textColor = [UIColor whiteColor];
  90. // PacketLossTipLabel.text = NSLocalizedString(@"webrtc_msg_PacketLoss",nil);
  91. // [blackBgView addSubview:PacketLossTipLabel];
  92. // //delayedTipLabel.backgroundColor = [UIColor redColor];
  93. //
  94. // [PacketLossTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  95. // make.centerX.mas_equalTo(- 1.5*laberW -10);
  96. // make.width.mas_equalTo(laberW);
  97. // make.height.mas_equalTo(laberH);
  98. // make.top.mas_equalTo(laberTop);
  99. // }];
  100. //
  101. _PacketLossLabel = [[UILabel alloc] init];
  102. _PacketLossLabel.font = [UIFont systemFontOfSize:12.0];
  103. _PacketLossLabel.textAlignment = NSTextAlignmentCenter;
  104. _PacketLossLabel.textColor = [UIColor whiteColor];//[UIColor hwColor:@"#FF2855"];
  105. //_PacketLossLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
  106. [_blackBgView addSubview:_PacketLossLabel];
  107. //_PacketLossLabel.backgroundColor = [UIColor redColor];
  108. [_PacketLossLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  109. //make.left.mas_equalTo(PacketLossTipLabel.mas_right).offset(0);
  110. make.centerX.mas_equalTo(self.mas_centerX);
  111. make.width.mas_equalTo(laberW*3.0);
  112. make.height.mas_equalTo(laberH);
  113. make.top.mas_equalTo(laberTop);
  114. }];
  115. //带宽
  116. // UILabel * speedLossTipLabel = [[UILabel alloc] init];
  117. // speedLossTipLabel.font = [UIFont systemFontOfSize:12.0];
  118. // speedLossTipLabel.textColor = [UIColor whiteColor];
  119. // speedLossTipLabel.text = NSLocalizedString(@"webrtc_msg_speed",nil);
  120. // [blackBgView addSubview:speedLossTipLabel];
  121. // //speedLossTipLabel.backgroundColor = [UIColor redColor];
  122. //
  123. // [speedLossTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  124. // make.centerX.mas_equalTo(1.5*laberW -10);
  125. // make.width.mas_equalTo(laberW +10 );
  126. // make.height.mas_equalTo(laberH);
  127. // make.top.mas_equalTo(laberTop);
  128. // }];
  129. _speedLabel = [[UILabel alloc] init];
  130. _speedLabel.font = [UIFont systemFontOfSize:12.0];
  131. _speedLabel.textColor = [UIColor whiteColor];
  132. _speedLabel.textAlignment = NSTextAlignmentRight;
  133. //_speedLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
  134. [_blackBgView addSubview:_speedLabel];
  135. //_speedLabel.backgroundColor = [UIColor redColor];
  136. [_speedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  137. //make.centerX.mas_equalTo(1.5*laberW);
  138. //make.centerX.mas_equalTo(self.mas_centerX);
  139. make.right.mas_equalTo(-15);
  140. make.width.mas_equalTo(laberW*3.0);
  141. make.height.mas_equalTo(laberH);
  142. make.top.mas_equalTo(laberTop);
  143. }];
  144. //fps
  145. // UILabel * fpsTipLabel = [[UILabel alloc] init];
  146. // fpsTipLabel.font = [UIFont systemFontOfSize:12.0];
  147. // fpsTipLabel.textColor = [UIColor whiteColor];
  148. // fpsTipLabel.text = @"FPS:";
  149. // [blackBgView addSubview:fpsTipLabel];
  150. // //speedLossTipLabel.backgroundColor = [UIColor redColor];
  151. //
  152. // [fpsTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  153. // make.right.mas_equalTo(- 15 - 0.5*laberW);
  154. // make.width.mas_equalTo(laberW);
  155. // make.height.mas_equalTo(laberH);
  156. // make.top.mas_equalTo(laberTop);
  157. // }];
  158. //_fpsLabel = [[UILabel alloc] init];
  159. // _fpsLabel.textAlignment = NSTextAlignmentRight;
  160. // _fpsLabel.font = [UIFont systemFontOfSize:12.0];
  161. // _fpsLabel.textColor = [UIColor whiteColor];
  162. // //_fpsLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
  163. // [_blackBgView addSubview:_fpsLabel];
  164. // //_fpsLabel.backgroundColor = [UIColor redColor];
  165. //
  166. // [_fpsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  167. // make.right.mas_equalTo(-15);
  168. // make.width.mas_equalTo(laberW*2);
  169. // make.height.mas_equalTo(laberH);
  170. // make.top.mas_equalTo(laberTop);
  171. // }];
  172. [self setWebRctMsgBydelayed:0 withPacketLoss:0.0 withSpeed:@"-" withFPS:@"-"];
  173. /***************************分辨率*******************************************************/
  174. _bg0View = [UIView new];
  175. _bg0View.layer.cornerRadius = 8;
  176. _bg0View.backgroundColor = [UIColor hwColor:@"#29313D"];
  177. [_blackBgView addSubview:_bg0View];
  178. [_bg0View mas_makeConstraints:^(MASConstraintMaker *make) {
  179. make.height.mas_equalTo(36);
  180. make.left.mas_equalTo(12);
  181. make.right.mas_equalTo(-12);
  182. //make.top.mas_equalTo(16.f);
  183. make.top.mas_equalTo(62.f);
  184. }];
  185. //分辨率
  186. UILabel *resolutionTipLabel = [[UILabel alloc] init];
  187. resolutionTipLabel.text = NSLocalizedString(@"cloudPhone_player_set_resolution",nil);
  188. resolutionTipLabel.textColor = [UIColor whiteColor];
  189. resolutionTipLabel.font = [UIFont systemFontOfSize:12.0];
  190. [_bg0View addSubview:resolutionTipLabel];
  191. [resolutionTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  192. make.left.mas_equalTo(15);
  193. make.top.equalTo(_bg0View.mas_top).offset(0);
  194. make.bottom.equalTo(_bg0View.mas_bottom).offset(0);
  195. }];
  196. _resolution720Button = [[UIButton alloc] init];
  197. _resolution720Button.layer.cornerRadius = 5;
  198. _resolution720Button.backgroundColor = [UIColor hwColor:@"#D8D8D8" alpha:0.09];
  199. [_resolution720Button setTitle:@"720*1280" forState:UIControlStateNormal];
  200. [_resolution720Button setTitleColor:[UIColor hwColor:@"#FFFFFF"] forState:UIControlStateNormal];
  201. _resolution720Button.titleLabel.font = [UIFont systemFontOfSize:12.0];
  202. _resolution720Button.layer.masksToBounds = YES;
  203. [_resolution720Button addTarget:self action:@selector(didClickResolution720ButFun) forControlEvents:UIControlEventTouchUpInside];
  204. [_bg0View addSubview:_resolution720Button];
  205. [_resolution720Button mas_makeConstraints:^(MASConstraintMaker *make) {
  206. make.left.mas_equalTo(80);
  207. make.width.mas_equalTo(93);
  208. make.height.mas_equalTo(26);
  209. make.centerY.mas_equalTo(0);
  210. }];
  211. _resolution1080Button = [[UIButton alloc] init];
  212. _resolution1080Button.layer.cornerRadius = 5;
  213. _resolution1080Button.backgroundColor = [UIColor hwColor:@"#D8D8D8" alpha:0.09];
  214. [_resolution1080Button setTitle:@"1080*1920" forState:UIControlStateNormal];
  215. [_resolution1080Button setTitleColor:[UIColor hwColor:@"#FFFFFF"] forState:UIControlStateNormal];
  216. _resolution1080Button.titleLabel.font = [UIFont systemFontOfSize:12.0];
  217. _resolution1080Button.layer.masksToBounds = YES;
  218. [_resolution1080Button addTarget:self action:@selector(didClickResolution1080ButFun) forControlEvents:UIControlEventTouchUpInside];
  219. [_bg0View addSubview:_resolution1080Button];
  220. [_resolution1080Button mas_makeConstraints:^(MASConstraintMaker *make) {
  221. make.right.mas_equalTo(-12);
  222. make.width.mas_equalTo(93);
  223. make.height.mas_equalTo(26);
  224. make.centerY.mas_equalTo(0);
  225. }];
  226. // gradient
  227. _glayer = [CAGradientLayer layer];
  228. _glayer.frame = CGRectMake(0, 0, 93, 26);
  229. _glayer.startPoint = CGPointMake(0, 0.5);
  230. _glayer.endPoint = CGPointMake(0.97, 0.5);
  231. _glayer.colors = @[(__bridge id)[UIColor hwColor:@"#0CDEFD" alpha:1.0].CGColor, (__bridge id)[UIColor hwColor:@"#058DFB" alpha:1.0].CGColor];
  232. _glayer.locations = @[@(0), @(1.0f)];
  233. [self firstSetResolutionFun];
  234. /***************************全面屏相关*******************************************************/
  235. _bg1View = [UIView new];
  236. // bg1View.layer.cornerRadius = 12;
  237. // bg1View.backgroundColor = [UIColor hwColor:@"#29313D"];
  238. [_blackBgView addSubview:_bg1View];
  239. [_bg1View mas_makeConstraints:^(MASConstraintMaker *make) {
  240. make.height.mas_equalTo(42);
  241. make.left.mas_equalTo(12);
  242. make.right.mas_equalTo(-12);
  243. make.top.mas_equalTo(112.f);
  244. //make.top.mas_equalTo(54.f);
  245. }];
  246. UIView *bgBottomNavView = [UIView new];
  247. bgBottomNavView.layer.cornerRadius = 8;
  248. bgBottomNavView.backgroundColor = [UIColor hwColor:@"#29313D"];
  249. [_blackBgView addSubview:bgBottomNavView];
  250. [bgBottomNavView mas_makeConstraints:^(MASConstraintMaker *make) {
  251. make.bottom.mas_equalTo(_bg1View.mas_bottom);
  252. make.left.mas_equalTo(12);
  253. make.right.equalTo(self.mas_centerX).offset(-6);
  254. //make.top.mas_equalTo(16.f);
  255. make.top.mas_equalTo(_bg1View.mas_top);
  256. }];
  257. UILabel *navSwitchTipLabel = [[UILabel alloc] init];
  258. navSwitchTipLabel.text = NSLocalizedString(@"cloudPhone_nav_show_tip",nil);
  259. //navSwitchTipLabel.textAlignment = NSTextAlignmentCenter;
  260. navSwitchTipLabel.textColor = [UIColor whiteColor];
  261. navSwitchTipLabel.font = [UIFont systemFontOfSize:12.0];
  262. [bgBottomNavView addSubview:navSwitchTipLabel];
  263. [navSwitchTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  264. make.left.mas_equalTo(15);
  265. make.top.equalTo(bgBottomNavView.mas_top).offset(0);
  266. make.bottom.equalTo(bgBottomNavView.mas_bottom).offset(0);
  267. }];
  268. //底部导航栏开关
  269. _bottomNavSwitch = [[SYJUISwitch alloc] initWithFrame:CGRectMake(0, 0, 44, 22)];
  270. _bottomNavSwitch.onTintColor = HW13B2EBColor;
  271. _bottomNavSwitch.offTintColor = [UIColor hwColor:@"#E3E8F1"];
  272. [_bottomNavSwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:UIControlEventValueChanged];
  273. [bgBottomNavView addSubview:_bottomNavSwitch];
  274. [_bottomNavSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
  275. make.right.mas_equalTo(-15.f);
  276. make.centerY.mas_equalTo(0.f);
  277. make.width.mas_equalTo(44.f);
  278. make.height.mas_equalTo(22.f);
  279. }];
  280. //全面屏开关
  281. UIView *bgFullScreenView = [UIView new];
  282. bgFullScreenView.layer.cornerRadius = 8;
  283. bgFullScreenView.backgroundColor = [UIColor hwColor:@"#29313D"];
  284. [_blackBgView addSubview:bgFullScreenView];
  285. [bgFullScreenView mas_makeConstraints:^(MASConstraintMaker *make) {
  286. make.bottom.mas_equalTo(_bg1View.mas_bottom);
  287. make.right.mas_equalTo(-12);
  288. make.left.equalTo(self.mas_centerX).offset(6);
  289. //make.top.mas_equalTo(16.f);
  290. make.top.mas_equalTo(_bg1View.mas_top);
  291. }];
  292. UILabel *fullScreenTipLabel = [[UILabel alloc] init];
  293. fullScreenTipLabel.text = NSLocalizedString(@"cloudPhone_fullScreen_show_tip",nil);
  294. //fullScreenTipLabel.textAlignment = NSTextAlignmentCenter;
  295. fullScreenTipLabel.textColor = [UIColor whiteColor];
  296. fullScreenTipLabel.font = [UIFont systemFontOfSize:12.0];
  297. [bgFullScreenView addSubview:fullScreenTipLabel];
  298. [fullScreenTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  299. make.left.mas_equalTo(15);
  300. make.top.equalTo(bgFullScreenView.mas_top).offset(0);
  301. make.bottom.equalTo(bgFullScreenView.mas_bottom).offset(0);
  302. }];
  303. _fullScreenSwitch = [[SYJUISwitch alloc] initWithFrame:CGRectMake(0, 0, 44, 22)];
  304. _fullScreenSwitch.onTintColor = HW13B2EBColor;
  305. _fullScreenSwitch.offTintColor = [UIColor hwColor:@"#E3E8F1"];
  306. [_fullScreenSwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:UIControlEventValueChanged];
  307. [bgFullScreenView addSubview:_fullScreenSwitch];
  308. [_fullScreenSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
  309. make.right.mas_equalTo(-15.f);
  310. make.centerY.mas_equalTo(0.f);
  311. make.width.mas_equalTo(44.f);
  312. make.height.mas_equalTo(22.f);
  313. }];
  314. KWeakSelf
  315. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  316. [weakSelf setAllSwitchFun];
  317. });
  318. /**********************************************************************************/
  319. UIView *bg2View = [UIView new];
  320. bg2View.layer.cornerRadius = 12;
  321. bg2View.backgroundColor = [UIColor hwColor:@"#29313D"];
  322. [_blackBgView addSubview:bg2View];
  323. [bg2View mas_makeConstraints:^(MASConstraintMaker *make) {
  324. make.height.mas_equalTo(72);
  325. make.left.mas_equalTo(15);
  326. make.right.mas_equalTo(-15);
  327. make.top.equalTo(_bg1View.mas_bottom).offset(12);
  328. //make.top.mas_equalTo(52);
  329. }];
  330. NSArray *titleArr = @[NSLocalizedString(@"cloudPhone_set_screenshot_tip",nil),
  331. NSLocalizedString(@"my_set_no_TV_p2p",nil),//my_set_no_close_TV_p2p
  332. NSLocalizedString(@"my_set_no_restart_phone",nil),
  333. //NSLocalizedString(@"cloudPhone_set_exit_tip",nil),
  334. ];
  335. NSArray *imageArr = @[@"cloudPhone_set_screenshot",
  336. @"cloudPhone_set_TV",
  337. @"cloudPhone_set_restart",
  338. //@"cloudPhone_set_exit",
  339. ];
  340. CGFloat butTopY = 15.0;
  341. CGFloat imageWH = 24.0;
  342. CGFloat butHeight = imageWH +20 +5;
  343. CGFloat butWidth = (320 -15*2)/3.0; //70.0;
  344. //CGFloat butWidth = (245 -12*2)/2.0; //70.0;
  345. CGFloat butSpace = 0.0; //(245 - butWidth*3)/3.0;
  346. for (int i=0; i<titleArr.count; i++) {
  347. UIButton *but = [[UIButton alloc] init];
  348. //but.tag = 10+i;
  349. but.tag = 200+i;
  350. [but addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  351. [bg2View addSubview:but];
  352. //but.backgroundColor = [UIColor greenColor];
  353. [but mas_makeConstraints:^(MASConstraintMaker *make) {
  354. make.left.mas_equalTo(butSpace + (butWidth+butSpace)*(i%4));
  355. make.width.mas_equalTo(butWidth);
  356. make.height.mas_equalTo(butHeight);
  357. make.top.mas_equalTo(butTopY + (i/4)* (butHeight + 25) );
  358. }];
  359. UIImageView *imageV = [[UIImageView alloc] init];
  360. imageV.image = [UIImage imageNamed:imageArr[i]];
  361. [but addSubview:imageV];
  362. [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
  363. make.centerX.mas_equalTo(0);
  364. make.width.mas_equalTo(imageWH);
  365. make.height.mas_equalTo(imageWH);
  366. make.top.mas_equalTo(0);
  367. }];
  368. UILabel *textLabel = [[UILabel alloc] init];
  369. textLabel.textAlignment = NSTextAlignmentCenter;
  370. textLabel.font = [UIFont systemFontOfSize:12.0];
  371. textLabel.textColor = [UIColor whiteColor];
  372. textLabel.text = titleArr[i];
  373. [but addSubview:textLabel];
  374. //textLabel.backgroundColor = [UIColor redColor];
  375. [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  376. make.centerX.mas_equalTo(0);
  377. make.width.mas_equalTo(butWidth);
  378. make.height.mas_equalTo(20);
  379. make.top.equalTo(imageV.mas_bottom).offset(0);
  380. }];
  381. if(i==1){
  382. _TVButton = but;
  383. _TVShowLabel = textLabel;
  384. [self getCouldPhoneTvStatusFun:nil];
  385. }
  386. }
  387. /**********************************************************************************/
  388. NSString *titleStr = [[NSString alloc] initWithFormat:@" %@",NSLocalizedString(@"cloudPhone_set_exit_tip",nil)];
  389. _exitPhoneButton = [[UIButton alloc] init];
  390. _exitPhoneButton.tag = 100;
  391. [_exitPhoneButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  392. [_exitPhoneButton setTitle:titleStr forState:(UIControlStateNormal)];
  393. [_exitPhoneButton setImage:[UIImage imageNamed:@"cloudPhone_set_exit"] forState:UIControlStateNormal];
  394. _exitPhoneButton.layer.cornerRadius = 12;
  395. [_exitPhoneButton.titleLabel setFont:[UIFont systemFontOfSize:12.f]];
  396. _exitPhoneButton.backgroundColor = [UIColor hwColor:@"#29313D"];
  397. [_blackBgView addSubview:_exitPhoneButton];
  398. // if(ksharedAppDelegate.TvStatusMod.isTVShowType){
  399. // _TVButton.selected = YES;
  400. // }
  401. [_exitPhoneButton mas_makeConstraints:^(MASConstraintMaker *make) {
  402. make.height.mas_equalTo(42);
  403. make.left.mas_equalTo(12);
  404. make.right.mas_equalTo(-12);
  405. make.top.equalTo(bg2View.mas_bottom).offset(12);
  406. }];
  407. [self handleResolutionUIFun];
  408. }
  409. - (void)setAllSwitchFun
  410. {
  411. BOOL haveShowBottonNavType = ![HWDataManager getBoolWithKey:Consn_player_Nav_hide];
  412. [_bottomNavSwitch setOn:haveShowBottonNavType];
  413. BOOL fullscreenType = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
  414. [_fullScreenSwitch setOn:fullscreenType];
  415. }
  416. - (void)maskSwitchPressed:(SYJUISwitch *)maskSwitch{
  417. if(_bottomNavSwitch == maskSwitch){
  418. if (maskSwitch.on) {
  419. [HWDataManager setBoolWithKey:Consn_player_Nav_hide value:NO];
  420. }
  421. else{
  422. [HWDataManager setBoolWithKey:Consn_player_Nav_hide value:YES];
  423. }
  424. [[NSNotificationCenter defaultCenter] postNotificationName:getPlayerBottomNavNotification object:nil];
  425. }
  426. else if (_fullScreenSwitch == maskSwitch){
  427. BOOL isTVShowType = ksharedAppDelegate.TvStatusMod.isTVShowType;
  428. if(isTVShowType){
  429. [[iToast makeText:NSLocalizedString(@"cloudPhone_tvShow_before_fullscreen_tip",nil)] show];
  430. [self removeFun];
  431. return;
  432. }
  433. if (maskSwitch.on) {
  434. [HWDataManager setBoolWithKey:Consn_player_full_screen_show value:YES];
  435. //数据埋点
  436. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Cloud_full_screen_on"];
  437. }
  438. else{
  439. [HWDataManager setBoolWithKey:Consn_player_full_screen_show value:NO];
  440. //数据埋点
  441. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Cloud_full_screen_off"];
  442. }
  443. [self handleResolutionUIFun];
  444. [[NSNotificationCenter defaultCenter] postNotificationName:setPlayerFullScreenNotification object:nil];
  445. }
  446. //[self removeFun];
  447. }
  448. #pragma mark 按钮事件
  449. - (void)didClickButtonFun:(UIButton*)but
  450. {
  451. NSInteger tag = but.tag;
  452. HLog(@"%ld",tag);
  453. [self removeFun];
  454. if(tag == 1){
  455. return;
  456. }
  457. if(tag == 201 && but.selected){
  458. tag = 301;
  459. }
  460. if(_didClickButtonFun){
  461. _didClickButtonFun(tag);
  462. }
  463. }
  464. - (void)removeFun
  465. {
  466. [self removeFromSuperview];
  467. }
  468. - (void)getCouldPhoneTvStatusFun:(NSNotification*)not
  469. {
  470. if(ksharedAppDelegate.TvStatusMod.isTVShowType){
  471. _TVButton.selected = YES;
  472. _TVShowLabel.text = NSLocalizedString(@"my_set_no_close_TV_p2p",nil);
  473. }
  474. else{
  475. _TVButton.selected = NO;
  476. _TVShowLabel.text = NSLocalizedString(@"my_set_no_TV_p2p",nil);
  477. }
  478. }
  479. - (void)setWebRctMsgBydelayed:(NSInteger)delayedMS withPacketLoss:(double)PacketLoss withSpeed:(NSString*)speedStr withFPS:(NSString*)fpsStr
  480. {
  481. //网络延迟: [0, 50ms)= 绿色 #22A082 ,[50ms, 100ms= 黄色, [100ms, ∞)= 红色 #FF2855
  482. if (delayedMS >= 100) {
  483. _delayedLabel.textColor = [UIColor hwColor:@"#FF2855"];
  484. }
  485. else if (delayedMS >= 50){
  486. _delayedLabel.textColor = [UIColor yellowColor];
  487. }
  488. else{
  489. _delayedLabel.textColor = [UIColor hwColor:@"22A082"];
  490. }
  491. if(delayedMS >= 1000){
  492. _delayedLabel.text = [[NSString alloc] initWithFormat:@"%lds",delayedMS/1000];
  493. }
  494. else{
  495. _delayedLabel.text = [[NSString alloc] initWithFormat:@"%ldms",delayedMS];
  496. }
  497. NSString*LossleftStr = NSLocalizedString(@"webrtc_msg_PacketLoss",nil);
  498. NSString*LossRightStr = [[NSString alloc] initWithFormat:@"%.02f%%",PacketLoss];
  499. NSString *LossfullTitle = [[NSString alloc] initWithFormat:@"%@%@",LossleftStr,LossRightStr];
  500. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:LossfullTitle];
  501. NSRange rightRange = NSMakeRange([LossfullTitle rangeOfString:LossRightStr].location, LossRightStr.length);
  502. UIColor *rightColor = [UIColor hwColor:@"22A082"];
  503. if(PacketLoss >= 5 && PacketLoss < 10){
  504. rightColor = [UIColor yellowColor];
  505. }
  506. else if(PacketLoss >= 10){
  507. rightColor = [UIColor hwColor:@"#FF2855"];
  508. }
  509. [attrStr addAttribute:NSForegroundColorAttributeName value:rightColor range:rightRange];
  510. _PacketLossLabel.attributedText = attrStr;
  511. _speedLabel.text = [[NSString alloc] initWithFormat:@"%@%@",NSLocalizedString(@"webrtc_msg_speed",nil),speedStr];
  512. //_fpsLabel.text = [[NSString alloc] initWithFormat:@"FPS:%@",fpsStr];
  513. }
  514. #pragma mark 设置分辨率
  515. - (void)firstSetResolutionFun
  516. {
  517. NSInteger curResolution = [HWDataManager getIntegerWithKey:Const_cloudPhone_cur_resolution];
  518. if(curResolution == 0 || curResolution == 1){
  519. _resolution720Button.selected = YES;
  520. [_resolution720Button.layer insertSublayer:_glayer atIndex:0];
  521. }
  522. else{
  523. _resolution1080Button.selected = YES;
  524. [_resolution1080Button.layer insertSublayer:_glayer atIndex:0];
  525. }
  526. }
  527. #pragma mark 是否要显示设置分辨率(全面屏要隐藏)
  528. - (void)handleResolutionUIFun
  529. {
  530. BOOL isHide = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
  531. if (isHide) {
  532. [_blackBgView mas_updateConstraints:^(MASConstraintMaker *make) {
  533. make.height.mas_equalTo(260);//(256);
  534. }];
  535. _bg0View.hidden = YES;
  536. [_bg1View mas_updateConstraints:^(MASConstraintMaker *make) {
  537. make.top.mas_equalTo(62);
  538. }];
  539. }
  540. else{
  541. [_blackBgView mas_updateConstraints:^(MASConstraintMaker *make) {
  542. make.height.mas_equalTo(260 + 50);//(256);
  543. }];
  544. _bg0View.hidden = NO;
  545. [_bg1View mas_updateConstraints:^(MASConstraintMaker *make) {
  546. make.top.mas_equalTo(112);
  547. }];
  548. }
  549. }
  550. #pragma mark 点击了分辨率720
  551. - (void)didClickResolution720ButFun
  552. {
  553. if(_resolution720Button.selected){
  554. return;
  555. }
  556. _resolution1080Button.selected = NO;
  557. _resolution720Button.selected = YES;
  558. [_resolution720Button.layer insertSublayer:_glayer atIndex:0];
  559. if(_didClickButtonFun){
  560. _didClickButtonFun(1);
  561. }
  562. [HWDataManager setIntegerWithKey:Const_cloudPhone_cur_resolution value:1];
  563. }
  564. #pragma mark 点击了分辨率1080
  565. - (void)didClickResolution1080ButFun
  566. {
  567. if(_resolution1080Button.selected){
  568. return;
  569. }
  570. _resolution720Button.selected = NO;
  571. _resolution1080Button.selected = YES;
  572. [_resolution1080Button.layer insertSublayer:_glayer atIndex:0];
  573. if(_didClickButtonFun){
  574. _didClickButtonFun(2);
  575. }
  576. [HWDataManager setIntegerWithKey:Const_cloudPhone_cur_resolution value:2];
  577. }
  578. @end