playerSetView.m 29 KB

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