playerSetView.m 28 KB

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