cloudPhoneViewController.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. //
  2. // cloudPhoneViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/6/20.
  6. //
  7. #import "cloudPhoneViewController.h"
  8. #import "cloudPhoneSetView.h"
  9. #import "PlayerViewController.h"
  10. #import "audioPlayingView.h"
  11. #import "DFPlayer.h"
  12. #import "audioPlayerViewController.h"
  13. @interface cloudPhoneViewController ()
  14. @property (nonatomic,strong) cloudPhoneSetView *cloudPhoneSetV;
  15. @end
  16. @implementation cloudPhoneViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. // Do any additional setup after loading the view.
  20. [self.view setBackgroundColor:HWF5F7FAColor];
  21. [self.toolBar setHidden:YES];
  22. [self.navigationBar setHidden:YES];
  23. [self.navBarBGView setHidden:YES];
  24. [self drawAnyView];
  25. }
  26. - (void)drawAnyView{
  27. //顶底底部图片
  28. UIImageView *topImageV = [UIImageView new];
  29. topImageV.userInteractionEnabled = YES;
  30. topImageV.image = [UIImage imageNamed:@"cloudPhone_bg"];
  31. [self.view addSubview:topImageV];
  32. [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.top.mas_equalTo(0);
  34. make.left.mas_equalTo(0);
  35. make.right.mas_equalTo(0);
  36. make.bottom.mas_equalTo(0);
  37. }];
  38. CGFloat imageTopY = 54.0;
  39. //设置按钮
  40. UIButton *setButton = [[UIButton alloc] init];
  41. //[setButton setBackgroundImage:[UIImage imageNamed:@"cloudPhone_set"] forState:UIControlStateNormal];
  42. [setButton setImage:[UIImage imageNamed:@"cloudPhone_set"] forState:UIControlStateNormal];
  43. setButton.tag = 1;
  44. [setButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  45. [self.view addSubview:setButton];
  46. //setButton.backgroundColor = [UIColor greenColor];
  47. [setButton mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.top.mas_equalTo(imageTopY);
  49. make.right.mas_equalTo(-16);
  50. make.width.mas_equalTo(50);
  51. make.height.mas_equalTo(50);
  52. // make.top.mas_equalTo(imageTopY);
  53. // make.right.mas_equalTo(-16);
  54. // make.width.mas_equalTo(24);
  55. // make.height.mas_equalTo(24);
  56. }];
  57. //中间图片
  58. UIImageView *midImageV = [UIImageView new];
  59. midImageV.userInteractionEnabled = YES;
  60. midImageV.image = [UIImage imageNamed:@"cloudPhone_mid_img"];
  61. [self.view addSubview:midImageV];
  62. [midImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.width.mas_equalTo(326*WAUTOSCALE);
  64. make.height.mas_equalTo(608*WAUTOSCALE);
  65. make.centerX.mas_equalTo(0);
  66. make.centerY.mas_equalTo(-10);
  67. }];
  68. NSString *midTopTipImageStr = @"cloudPhone_topTip_img_cs";
  69. //欢迎
  70. //en-US 英文 ja-JP 日文
  71. NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
  72. NSLog(@"arLanguages:%@",arLanguages);
  73. ///获取设备当前地区的代码和APP语言环境
  74. NSString *languageCode = [NSLocale preferredLanguages][0];
  75. //目前支持 中文(简体 繁体) 英文 日语
  76. if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
  77. {
  78. midTopTipImageStr = @"cloudPhone_topTip_img_cs";
  79. }
  80. else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
  81. {
  82. midTopTipImageStr = @"cloudPhone_topTip_img_ct";
  83. }
  84. else{
  85. midTopTipImageStr = @"cloudPhone_topTip_img_en";
  86. }
  87. //提示文字图片
  88. UIImageView *midTopTipImageV = [UIImageView new];
  89. midTopTipImageV.image = [UIImage imageNamed:midTopTipImageStr];
  90. [midImageV addSubview:midTopTipImageV];
  91. [midTopTipImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.width.mas_equalTo(282*WAUTOSCALE);
  93. make.height.mas_equalTo(84*WAUTOSCALE);
  94. make.centerX.mas_equalTo(0);
  95. make.top.equalTo(midImageV.mas_top).offset(64);
  96. }];
  97. //进入云机
  98. UIButton*enterCloudPhoneButton = [[UIButton alloc] init];
  99. CGFloat w_btn = SCREEN_W - 15*2 - 50*2;
  100. // gradient
  101. CAGradientLayer *gl = [CAGradientLayer layer];
  102. gl.frame = CGRectMake(0,0,w_btn,44.f);
  103. gl.startPoint = CGPointMake(0, 0.5);
  104. gl.endPoint = CGPointMake(0.97, 0.5);
  105. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  106. gl.locations = @[@(0), @(1.0f)];
  107. [enterCloudPhoneButton.layer addSublayer:gl];
  108. [enterCloudPhoneButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  109. //[enterCloudPhoneButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:(UIControlEventTouchUpInside)];
  110. [enterCloudPhoneButton setTitle:NSLocalizedString(@"cloudPhone_enter_tip",nil) forState:(UIControlStateNormal)];
  111. [enterCloudPhoneButton.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
  112. [enterCloudPhoneButton.layer setCornerRadius:21.f];
  113. enterCloudPhoneButton.layer.borderWidth = 1.5;
  114. enterCloudPhoneButton.layer.borderColor = [UIColor whiteColor].CGColor;
  115. enterCloudPhoneButton.clipsToBounds = YES;
  116. //enterCloudPhoneButton.tag = 2;
  117. [midImageV addSubview:enterCloudPhoneButton];
  118. [enterCloudPhoneButton mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.width.mas_equalTo(w_btn);
  120. make.height.mas_equalTo(42);
  121. make.centerX.mas_equalTo(0);
  122. make.bottom.equalTo(midImageV.mas_bottom).offset(-60);
  123. }];
  124. //扩大金融云机范围按钮
  125. UIButton *bigButton = [[UIButton alloc] init];
  126. bigButton.tag = 2;
  127. [bigButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  128. [self.view addSubview:bigButton];
  129. //bigButton.backgroundColor = [UIColor greenColor];
  130. [bigButton mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.top.equalTo(midImageV.mas_top).offset(0);
  132. make.right.equalTo(midImageV.mas_right).offset(0);
  133. make.left.equalTo(midImageV.mas_left).offset(0);
  134. make.bottom.equalTo(midImageV.mas_bottom).offset(0);
  135. }];
  136. }
  137. #pragma mark 点击按钮
  138. - (void)didClickButtonFun:(UIButton*)but
  139. {
  140. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  141. {
  142. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  143. return;
  144. }
  145. NSInteger tag = but.tag;
  146. HLog(@"%ld",tag);
  147. switch (tag) {
  148. case 1:
  149. {
  150. //数据埋点
  151. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Cloud_settings"];
  152. _cloudPhoneSetV = [cloudPhoneSetView new];
  153. [ksharedAppDelegate.window addSubview:_cloudPhoneSetV];
  154. [_cloudPhoneSetV mas_makeConstraints:^(MASConstraintMaker *make) {
  155. make.left.mas_equalTo(0);
  156. make.right.mas_equalTo(0);
  157. make.top.mas_equalTo(0);
  158. make.bottom.mas_equalTo(0);
  159. }];
  160. KWeakSelf
  161. _cloudPhoneSetV.didClickButtonFun = ^(NSInteger tag) {
  162. if (tag == 10) {//重启
  163. [weakSelf didClickRestartFun];
  164. }
  165. else if (tag == 11){//恢复出厂
  166. [weakSelf RestoreFactoryAleartFun];
  167. }
  168. };
  169. }
  170. break;
  171. case 2:
  172. {
  173. BOOL isTVShowType = ksharedAppDelegate.TvStatusMod.isTVShowType;
  174. if(isTVShowType){//关闭全屏屏
  175. [HWDataManager setBoolWithKey:Consn_player_full_screen_show value:NO];
  176. }
  177. BOOL fullscreenType = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
  178. //重新设置分辨率
  179. if(fullscreenType){
  180. NSString *commandStr = [RCCommandHelp commondToSetFullScreenPhoneSize];
  181. [[webSocketManager shareInstance] send_data:commandStr];
  182. }
  183. else{
  184. if ((ksharedAppDelegate.couldPhone_W_PHONE == 720 && ksharedAppDelegate.couldPhone_H_PHONE == 1280)
  185. || (ksharedAppDelegate.couldPhone_W_PHONE == 1080 && ksharedAppDelegate.couldPhone_H_PHONE == 1920)) {//云机可能存在的分辨率
  186. }
  187. else{
  188. NSString *commondStr = @"{\"data\":{\"height\":1920,\"width\":1080},\"type\":\"setPhoneSize\"}";
  189. [[webSocketManager shareInstance] send_data:commondStr];
  190. }
  191. }
  192. PlayerViewController *vc = [PlayerViewController new];
  193. [self pushViewController:vc animated:YES];
  194. if(ksharedAppDelegate.TvStatusMod.isTVShowType){
  195. [[iToast makeText:NSLocalizedString(@"tv_p2p_ing",nil)] show];
  196. }
  197. //数据埋点
  198. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Cloud_enter"];
  199. }
  200. break;
  201. default:
  202. break;
  203. }
  204. }
  205. #pragma mark 点击了重启空间
  206. - (void)didClickRestartFun
  207. {
  208. KWeakSelf
  209. /*弹窗提示重启*/
  210. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_restart_phone_tips",nil)
  211. msg:@""
  212. imageStr:@""
  213. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  214. okTitle:NSLocalizedString(@"my_set_no_restart_phone_btn_ok",nil) isOkBtnHighlight:NO
  215. didClickOk:^{
  216. [weakSelf sureToRestartCloudPhoneFun];
  217. } didClickCancel:^{
  218. }];
  219. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  220. [self presentViewController:nextVC animated:YES completion:^{
  221. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  222. }];
  223. }
  224. #pragma mark 确认重启云机
  225. - (void)sureToRestartCloudPhoneFun{
  226. // /*重启云手机*/
  227. // 通过指令通道发送 {"type":"reboot"}
  228. [[webSocketManager shareInstance] needToRebootFun];
  229. //提示语
  230. [[iToast makeText:NSLocalizedString(@"player_link_rebooting_Tips",nil)] show];
  231. }
  232. #pragma mark 点击恢复出厂
  233. - (void)RestoreFactoryAleartFun
  234. {
  235. KWeakSelf
  236. /*弹窗提示恢复出厂*/
  237. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_tips",nil)
  238. msg:NSLocalizedString(@"my_set_no_Restore_Factory_msg",nil)
  239. imageStr:@"icon_Restore_Factory_big"
  240. cancelTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil)
  241. okTitle:NSLocalizedString(@"other_cancel",nil) isOkBtnHighlight:YES
  242. didClickOk:^{
  243. } didClickCancel:^{
  244. //点击确定
  245. [weakSelf gotoResetFun];
  246. }];
  247. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  248. [self presentViewController:nextVC animated:YES completion:^{
  249. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  250. }];
  251. }
  252. #pragma mark 点击了恢复出厂
  253. - (void)gotoResetFun
  254. {
  255. [[webSocketManager shareInstance] needToResetFun];
  256. [self RestoreFactoryingFun];
  257. }
  258. #pragma mark 恢复出厂中
  259. - (void)RestoreFactoryingFun
  260. {
  261. KWeakSelf
  262. /*弹窗提示恢复出厂*/
  263. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factorying_tips",nil)
  264. msg:NSLocalizedString(@"my_set_no_Restore_Factorying_msg",nil)
  265. imageStr:@""
  266. cancelTitle:NSLocalizedString(@"my_set_no_Restore_Factorying",nil)
  267. okTitle:@""
  268. isOkBtnHighlight:NO
  269. didClickOk:^{
  270. [weakSelf RestoreFactoryCompleteFun];
  271. } didClickCancel:^{
  272. }];
  273. [nextVC setButtonCountdownFun:180];//90
  274. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  275. [self presentViewController:nextVC animated:YES completion:^{
  276. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  277. }];
  278. }
  279. #pragma mark 恢复出厂倒计时结束
  280. - (void)RestoreFactoryCompleteFun
  281. {
  282. //KWeakSelf
  283. //瑞云发起重连
  284. //[[connectDeviceManager shareInstance] onConnectFun];
  285. /*弹窗提示恢复出厂*/
  286. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_ok_tips",nil)
  287. msg:@""
  288. imageStr:@""
  289. cancelTitle:NSLocalizedString(@"my_set_no_Restore_FactoryOK",nil)
  290. okTitle:@""
  291. isOkBtnHighlight:NO
  292. didClickOk:^{
  293. } didClickCancel:^{
  294. }];
  295. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  296. [self presentViewController:nextVC animated:YES completion:^{
  297. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  298. }];
  299. }
  300. - (void)viewWillAppear:(BOOL)animated{
  301. [super viewWillAppear:animated];
  302. [self handelAudioPlayingViewFun];
  303. }
  304. - (void)viewWillDisappear:(BOOL)animated{
  305. [super viewWillDisappear:animated];
  306. }
  307. - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated
  308. {
  309. [self.navigationController pushViewController:vc animated:animated];
  310. }
  311. #pragma mark 处理音频播放中的视图状态
  312. - (void)handelAudioPlayingViewFun
  313. {
  314. audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  315. if([DFPlayer sharedPlayer].state == DFPlayerStateBuffering
  316. ||[DFPlayer sharedPlayer].state == DFPlayerStatePlaying
  317. ||[DFPlayer sharedPlayer].state == DFPlayerStatePause){//播放中
  318. [self showAudioPlayingViewFun];
  319. }
  320. else{
  321. [self hideAudioPlayingViewFun];
  322. }
  323. KWeakSelf
  324. audioPlayingV.didClickButtonFun = ^(NSInteger tag) {
  325. if(tag == 1){
  326. [weakSelf hideAudioPlayingViewFun];
  327. }
  328. else if(tag == 5){
  329. [weakSelf AudioPlayingGotoAudioPlayerVCFun];
  330. }
  331. };
  332. }
  333. - (void)AudioPlayingGotoAudioPlayerVCFun{
  334. audioPlayerViewController *vc = [audioPlayerViewController new];
  335. vc.isfirstEnterType = NO;
  336. [self.navigationController pushViewController:vc animated:YES];
  337. }
  338. #pragma mark 显示音频播放中的视图
  339. - (void)showAudioPlayingViewFun
  340. {
  341. audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  342. [self.view addSubview:audioPlayingV];
  343. [audioPlayingV mas_makeConstraints:^(MASConstraintMaker *make) {
  344. make.height.mas_equalTo(49);
  345. make.left.mas_equalTo(0);
  346. make.right.mas_equalTo(0);
  347. make.bottom.mas_equalTo(-TABBARHEIGHT);
  348. }];
  349. }
  350. #pragma mark 隐藏音频播放中的视图
  351. - (void)hideAudioPlayingViewFun
  352. {
  353. // audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  354. // [audioPlayingV removeFromSuperview];
  355. }
  356. @end