PlayerView.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. //
  2. // PlayerView.m
  3. // VclustersGemini
  4. //
  5. // Created by APPLE on 2019/6/13.
  6. // Copyright © 2019 APPLE. All rights reserved.
  7. //
  8. #import "PlayerView.h"
  9. #import "UIView+View.h"
  10. @interface PlayerView ()
  11. <UIGestureRecognizerDelegate,
  12. ShowImageViewDelegate>{
  13. EAGLContext *eagContext;
  14. CIContext *ciContext;
  15. CIFilter *filter;
  16. //触控指令视图,用于计算触控位置坐标
  17. ShowImageView *touchCommondView;
  18. UIView *bottomContrView;
  19. UIButton *mueBtn;
  20. UIButton *homeBtn;
  21. UIButton *backBtn;
  22. UIButton *showHomeBtn;
  23. }
  24. @end
  25. @implementation PlayerView
  26. @synthesize showImageView;
  27. @synthesize glkshowImageView;
  28. @synthesize controlBtn;
  29. @synthesize delegate;
  30. @synthesize isLan;
  31. - (id)initWithFrame:(CGRect)frame{
  32. self = [super initWithFrame:frame];
  33. if (self){
  34. [self setBackgroundColor:[UIColor blackColor]];
  35. [self initOpenGL];
  36. [self drawView:frame];
  37. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getPlayerBottomNavShowOrHidefun) name:getPlayerBottomNavNotification object:nil];
  38. }
  39. return self;
  40. }
  41. - (void)initOpenGL{
  42. eagContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
  43. ciContext = [CIContext contextWithEAGLContext:eagContext
  44. options:@{kCIContextWorkingColorSpace:[NSNull null]}];
  45. filter = [CIFilter filterWithName:@"CISepiaTone"];
  46. }
  47. - (void)glkShowImage:(CIImage *)ciImage{
  48. [filter setValue:ciImage forKey:kCIInputImageKey];
  49. [filter setValue:@(0) forKey:kCIInputIntensityKey];
  50. //开始渲染
  51. [ciContext drawImage:[filter valueForKey:kCIOutputImageKey]
  52. inRect:CGRectMake(0, 0, glkshowImageView.drawableWidth, glkshowImageView.drawableHeight)
  53. fromRect:[ciImage extent]];
  54. [self->glkshowImageView display];
  55. }
  56. - (void)showIMage
  57. {
  58. ;
  59. }
  60. - (void)drawView:(CGRect)frame{
  61. self.frame = frame;
  62. touchCommondView = [[ShowImageView alloc] init];
  63. [touchCommondView setBackgroundColor: [UIColor clearColor]];
  64. [touchCommondView setUserInteractionEnabled:YES];
  65. touchCommondView.multipleTouchEnabled = YES;
  66. touchCommondView.delegate = self;
  67. [self addSubview:touchCommondView];
  68. [touchCommondView mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.left.mas_equalTo(0.f);
  70. make.height.mas_equalTo(frame.size.height);
  71. make.right.mas_equalTo(0.f);
  72. make.top.mas_equalTo(0.f);
  73. }];
  74. //此方案弃用
  75. // UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapBeganFun)];
  76. // [touchCommondView addGestureRecognizer:tap];
  77. /*播放视图*/
  78. showImageView = [[ShowImageView alloc] init];
  79. [showImageView setBackgroundColor: [UIColor blackColor]];
  80. [showImageView setUserInteractionEnabled:NO];
  81. [showImageView setBackgroundColor:[UIColor blackColor]];
  82. glkshowImageView = [[GLKView alloc] initWithFrame:self.frame context:eagContext];
  83. [glkshowImageView setBackgroundColor:[UIColor blackColor]];
  84. [glkshowImageView bindDrawable];
  85. [glkshowImageView setUserInteractionEnabled:NO];
  86. [touchCommondView addSubview:showImageView];
  87. [showImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.left.mas_equalTo(0.f);
  89. make.right.mas_equalTo(0.f);
  90. make.bottom.mas_equalTo(0.f);
  91. make.top.mas_equalTo(0.f);
  92. }];
  93. [touchCommondView addSubview:glkshowImageView];
  94. [glkshowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.left.mas_equalTo(0.f);
  96. make.right.mas_equalTo(0.f);
  97. make.bottom.mas_equalTo(0.f);
  98. make.top.mas_equalTo(0.f);
  99. }];
  100. /*控制按钮*/
  101. UIImage *driftBtnImage = [UIImage imageNamed:@"you_icon"];
  102. controlBtn = [[UIButton alloc] init];
  103. [controlBtn setBackgroundColor:[UIColor clearColor]];
  104. [controlBtn addTarget:self
  105. action:@selector(controlBtnPressed:)
  106. forControlEvents:(UIControlEventTouchUpInside)];
  107. UIPanGestureRecognizer *gester = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureCallback:)];
  108. [controlBtn addGestureRecognizer:gester];
  109. gester.delegate = self;
  110. gester = nil;
  111. //[controlBtn setImage:driftBtnImage forState:(UIControlStateNormal)];
  112. [controlBtn setBackgroundImage:driftBtnImage forState:(UIControlStateNormal)];
  113. [controlBtn addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(controlBtnLongPress:)]];
  114. /*下方控制器*/
  115. bottomContrView = [[UIView alloc] initWithFrame:CGRectMake(0, frame.size.height - 47.f, frame.size.width, 47.f)];
  116. //[bottomContrView setBackgroundColor:[UIColor blackColor]];
  117. [bottomContrView setBackgroundColor:[UIColor clearColor]];
  118. [self addSubview:bottomContrView];
  119. [bottomContrView mas_makeConstraints:^(MASConstraintMaker *make) {
  120. make.right.mas_equalTo(0);
  121. make.height.mas_equalTo(47.f);
  122. make.left.mas_equalTo(0.f);
  123. make.bottom.mas_equalTo(0.f);
  124. }];
  125. [bottomContrView setHidden:YES];
  126. [self initAddSubViewForBottomContrView];
  127. [self setPoMas_makeWithImageRate:frame.size.width/frame.size.height isOpenVirtual:NO isUsageMode:NO];
  128. }
  129. - (void)initAddSubViewForBottomContrView{
  130. /*第一个app菜单*/
  131. UIImage *mueBtnImage = [UIImage imageNamed:@"houtai_icon"];
  132. mueBtn = [[UIButton alloc] init];
  133. [mueBtn setBackgroundColor:[UIColor clearColor]];
  134. [mueBtn addTarget:self
  135. action:@selector(mueBtnPressed:)
  136. forControlEvents:(UIControlEventTouchUpInside)];
  137. [mueBtn setImage:mueBtnImage forState:(UIControlStateNormal)];
  138. [mueBtn setImageEdgeInsets:(UIEdgeInsetsMake(6.f, 6.f, 6.f, 6.f))];
  139. [bottomContrView addSubview:mueBtn];
  140. /*第二个home键*/
  141. UIImage *homeBtnImage = [UIImage imageNamed:@"home_icon"];
  142. homeBtn = [[UIButton alloc] init];
  143. [homeBtn setBackgroundColor:[UIColor clearColor]];
  144. [homeBtn addTarget:self
  145. action:@selector(homeBtnPressed:)
  146. forControlEvents:(UIControlEventTouchUpInside)];
  147. [homeBtn setImage:homeBtnImage forState:(UIControlStateNormal)];
  148. [homeBtn setImageEdgeInsets:(UIEdgeInsetsMake(6.f, 6.f, 6.f, 6.f))];
  149. [bottomContrView addSubview:homeBtn];
  150. /*第三个返回键*/
  151. UIImage *backBtnImage = [UIImage imageNamed:@"fanhui_you_icon"];
  152. backBtn = [[UIButton alloc] init];
  153. [backBtn setBackgroundColor:[UIColor clearColor]];
  154. [backBtn addTarget:self
  155. action:@selector(backBtnPressed:)
  156. forControlEvents:(UIControlEventTouchUpInside)];
  157. [backBtn setImage:backBtnImage forState:(UIControlStateNormal)];
  158. [backBtn setImageEdgeInsets:(UIEdgeInsetsMake(6.f, 6.f, 6.f, 6.f))];
  159. [bottomContrView addSubview:backBtn];
  160. //测试说图片方向反了
  161. //backBtn.imageView.transform = CGAffineTransformMakeRotation(M_PI);
  162. /*第四个隐藏显示键*/
  163. UIImage *showBtnImage = [UIImage imageNamed:@"showOrhide_home_icon"];
  164. showHomeBtn = [[UIButton alloc] init];
  165. [showHomeBtn setBackgroundColor:[UIColor clearColor]];
  166. [showHomeBtn addTarget:self action:@selector(showOrHideHomeButtomFun:) forControlEvents:(UIControlEventTouchUpInside)];
  167. [showHomeBtn setImage:showBtnImage forState:(UIControlStateNormal)];
  168. [showHomeBtn setImageEdgeInsets:(UIEdgeInsetsMake(6.f, 6.f, 6.f, 6.f))];
  169. [bottomContrView addSubview:showHomeBtn];
  170. }
  171. - (void)mueBtnPressed:(id)sender{
  172. if ([delegate respondsToSelector:@selector(mueBtnBePressed:)]) {
  173. [delegate mueBtnBePressed:sender];
  174. }
  175. }
  176. - (void)homeBtnPressed:(id)sender{
  177. if ([delegate respondsToSelector:@selector(homeBtnBePressed:)]) {
  178. [delegate homeBtnBePressed:sender];
  179. }
  180. }
  181. - (void)backBtnPressed:(id)sender{
  182. if ([delegate respondsToSelector:@selector(backBtnBePressed:)]) {
  183. [delegate backBtnBePressed:sender];
  184. }
  185. }
  186. - (void)showOrHideHomeButtomFun:(UIButton*)but{
  187. but.selected = !but.selected;
  188. if(but.selected){
  189. but.imageView.transform = CGAffineTransformMakeRotation(M_PI);
  190. }
  191. else{
  192. but.imageView.transform = CGAffineTransformMakeRotation(0);
  193. }
  194. [self setShowOrHideBottomButtonsFunBy:but.selected];
  195. }
  196. - (void)initPoMas_makeWithImageRate:(BOOL)isOpenVirtual isUsageMode:(BOOL)isUsageMode{
  197. [self setPoMas_makeWithImageRate:self.frame.size.width/self.frame.size.height isOpenVirtual:isOpenVirtual isUsageMode:isUsageMode];
  198. }
  199. - (void)setPoMas_makeWithImageRate:(CGFloat)w_h_rate isOpenVirtual:(BOOL)isOpenVirtual isUsageMode:(BOOL)isUsageMode{
  200. /*播放视图*/
  201. // touchCommondView.isLan = NO;
  202. BOOL fullScreenShow = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
  203. [showImageView setBackgroundColor:[UIColor blackColor]];
  204. [touchCommondView mas_remakeConstraints:^(MASConstraintMaker *make) {
  205. CGFloat scr_W = SCREEN_W;
  206. CGFloat scr_H = SCREEN_H;
  207. if (SCREEN_W > SCREEN_H){
  208. scr_W = SCREEN_H;
  209. scr_H = SCREEN_W;
  210. }
  211. if ((scr_H - scr_W/w_h_rate - 40.f)/2.f < 0){
  212. if(fullScreenShow){
  213. make.height.mas_equalTo(scr_H);
  214. make.width.mas_equalTo(scr_W);
  215. }
  216. else{
  217. make.height.mas_equalTo(scr_H - 40.f);
  218. make.width.mas_equalTo((scr_H - 40.f)*w_h_rate);
  219. }
  220. make.centerX.equalTo(self.mas_centerX);
  221. make.top.mas_equalTo(0);
  222. }
  223. else{
  224. make.left.mas_equalTo(0.f);
  225. make.right.mas_equalTo(0.f);
  226. if(fullScreenShow){
  227. make.height.mas_equalTo(scr_H);
  228. make.top.mas_equalTo(0.f);
  229. }
  230. else{
  231. make.height.mas_equalTo(scr_W/w_h_rate);
  232. make.top.mas_equalTo((scr_H - scr_W/w_h_rate - 40.f)/2.f);
  233. }
  234. }
  235. }];
  236. [showImageView setTransform:CGAffineTransformMakeRotation(0)];
  237. [glkshowImageView setTransform:CGAffineTransformMakeRotation(0)];
  238. [showImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  239. make.left.equalTo(touchCommondView.mas_left);
  240. make.right.equalTo(touchCommondView.mas_right);
  241. make.top.equalTo(touchCommondView.mas_top);
  242. make.bottom.equalTo(touchCommondView.mas_bottom);
  243. }];
  244. [self.glkshowImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  245. make.left.equalTo(touchCommondView.mas_left);
  246. make.right.equalTo(touchCommondView.mas_right);
  247. make.top.equalTo(touchCommondView.mas_top);
  248. make.bottom.equalTo(touchCommondView.mas_bottom);
  249. }];
  250. [bottomContrView setHidden:NO];
  251. [bottomContrView mas_remakeConstraints:^(MASConstraintMaker *make) {
  252. make.height.mas_equalTo(40.f);
  253. make.right.equalTo(touchCommondView.mas_right);
  254. if(fullScreenShow){
  255. make.bottom.mas_equalTo(0);
  256. }
  257. else{
  258. make.top.equalTo(touchCommondView.mas_bottom);
  259. }
  260. make.left.equalTo(touchCommondView.mas_left);
  261. }];
  262. [mueBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  263. make.right.mas_equalTo(-80.f);
  264. make.width.and.height.mas_equalTo(40.f);
  265. make.top.mas_equalTo(0);
  266. }];
  267. [homeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  268. make.centerX.equalTo(bottomContrView.mas_centerX);
  269. make.width.and.height.mas_equalTo(40.f);
  270. make.top.mas_equalTo(0);
  271. }];
  272. UIImage *backBtnImage = [UIImage imageNamed:@"fanhui_you_icon"];
  273. // UIImage *backBtnImage = [UIImage imageNamed:@"fanhui_icon"];
  274. [backBtn setImage:backBtnImage forState:(UIControlStateNormal)];
  275. [backBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  276. make.left.mas_equalTo(80.f);
  277. make.width.and.height.mas_equalTo(40.f);
  278. make.top.mas_equalTo(0);
  279. }];
  280. [showHomeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  281. make.right.mas_equalTo(-20.f);
  282. make.width.and.height.mas_equalTo(40.f);
  283. make.top.mas_equalTo(0);
  284. }];
  285. [self getPlayerBottomNavShowOrHidefun];
  286. }
  287. /**
  288. * @brief 设置横屏模式UI布局
  289. *
  290. * @param w_h_rate 宽高比
  291. *
  292. * @param isOpenVirtual 是否有打开底部虚拟按键
  293. *
  294. * @param isUsageMode 是否为专业模式
  295. *
  296. */
  297. - (void)setLanMas_makeWithImageRate:(CGFloat)w_h_rate isOpenVirtual:(BOOL)isOpenVirtual isUsageMode:(BOOL)isUsageMode{
  298. /*需要考虑专业模式*/
  299. /*暂时只考虑非专业模式无虚拟键布局*/
  300. CGFloat h_forPhoneTop = 0;
  301. if (IPHONE_X){
  302. h_forPhoneTop = 44.f;
  303. }
  304. CGFloat des_W = SCREEN_W<SCREEN_H?SCREEN_W:SCREEN_H;/*实际较小的数字*/
  305. CGFloat des_H = (SCREEN_W>SCREEN_H?SCREEN_W:SCREEN_H) - h_forPhoneTop;/*实际较大的数字*/
  306. // touchCommondView.isLan = YES;
  307. [touchCommondView mas_remakeConstraints:^(MASConstraintMaker *make) {
  308. make.bottom.mas_equalTo(0.f);
  309. make.width.mas_equalTo(des_W*w_h_rate);
  310. make.left.mas_equalTo(h_forPhoneTop + (des_H - des_W*w_h_rate)/2.f);
  311. make.top.mas_equalTo(0);
  312. }];
  313. CGFloat des_H1 = des_W*w_h_rate;/*实际较大的数字*/
  314. CGFloat des_W1 = des_W;/*实际较小的数字*/
  315. if (isUsageMode){
  316. des_W1 = des_W-44.f;
  317. des_H1 = (des_W-44.f)*w_h_rate;
  318. }
  319. [showImageView setTransform:CGAffineTransformMakeRotation(-M_PI/2)];
  320. [glkshowImageView setTransform:CGAffineTransformMakeRotation(-M_PI/2)];
  321. [showImageView setBackgroundColor:[UIColor blackColor]];
  322. [showImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  323. make.height.mas_equalTo(des_H1);
  324. make.width.mas_equalTo((des_W1));
  325. make.left.mas_equalTo((des_H1 - des_W1)/2.f);
  326. make.top.mas_equalTo((des_W1 - des_H1)/2.f);
  327. }];
  328. [self.glkshowImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  329. /*动态处理宽高*/
  330. make.height.mas_equalTo(des_H1);
  331. make.width.mas_equalTo((des_W1));
  332. make.left.mas_equalTo((des_H1 - des_W1)/2.f);
  333. make.top.mas_equalTo((des_W1 - des_H1)/2.f);
  334. }];
  335. }
  336. - (void)controlBtnPressed:(id)sender{
  337. if ([delegate respondsToSelector:@selector(useInfoBtnBePressed:)]) {
  338. [delegate useInfoBtnBePressed:sender];
  339. }
  340. }
  341. static int sendCount = 0;
  342. #pragma -mark showImageViewDelegate
  343. - (void)showImageViewtouchesBeganCommondStr:(NSString *)commondStr{
  344. if ([delegate respondsToSelector:@selector(playerShowImageViewtouchesStr:)]){
  345. sendCount = 1;
  346. [delegate playerShowImageViewtouchesStr:commondStr];
  347. HLog(@"\n-----showImageViewtouchesBeganCommondStr-----");
  348. }
  349. }
  350. - (void)showImageViewtouchesEndedCommondStr:(NSString *)commondStr{
  351. if ([delegate respondsToSelector:@selector(playerShowImageViewtouchesStr:)]){
  352. HLog(@"\n-----showImageViewtouchesEndedCommondStr-----");
  353. sendCount = 0;
  354. [delegate playerShowImageViewtouchesStr:commondStr];
  355. }
  356. }
  357. - (void)showImageViewtouchesMovedCommondStr:(NSString *)commondStr{
  358. if ([delegate respondsToSelector:@selector(playerShowImageViewtouchesStr:)]){
  359. HLog(@"\n-----showImageViewtouchesMovedCommondStr-----");
  360. if (sendCount%2 == 0){
  361. [delegate playerShowImageViewtouchesStr:commondStr];
  362. }
  363. sendCount++;
  364. }
  365. }
  366. - (void)showImageViewtouchesCancelledCommondStr:(NSString *)commondStr{
  367. if ([delegate respondsToSelector:@selector(playerShowImageViewtouchesStr:)]){
  368. HLog(@"\n-----showImageViewtouchesCancelledCommondStr-----");
  369. sendCount = 0;
  370. [delegate playerShowImageViewtouchesStr:commondStr];
  371. }
  372. }
  373. - (void)controlBtnLongPress:(UILongPressGestureRecognizer *)longPressGesture {
  374. switch (longPressGesture.state) {
  375. case UIGestureRecognizerStateBegan:{
  376. // HLog(@"云手机推流界面 控制按钮长按手势开始");
  377. [[NSNotificationCenter defaultCenter] postNotificationName:PlayerViewControlBtnTouchBeganNotification object:nil userInfo:nil];
  378. break;
  379. case UIGestureRecognizerStateEnded:{
  380. // HLog(@"云手机推流界面 控制按钮长按手势结束");
  381. [[NSNotificationCenter defaultCenter] postNotificationName:PlayerViewControlBtnTouchEndNotification object:nil userInfo:nil];
  382. break;
  383. }
  384. default:
  385. break;
  386. }
  387. }
  388. }
  389. static CGRect startFrame;
  390. - (void)panGestureCallback:(UIPanGestureRecognizer *)panGesture{
  391. self.controlBtn.alpha = 1;
  392. switch (panGesture.state) {
  393. case UIGestureRecognizerStateBegan:{
  394. startFrame = controlBtn.frame;
  395. // HLog(@"云手机推流界面 控制按钮拖动手势开始");
  396. [[NSNotificationCenter defaultCenter] postNotificationName:PlayerViewControlBtnTouchBeganNotification object:nil userInfo:nil];
  397. break;
  398. }
  399. case UIGestureRecognizerStateChanged:{
  400. CGPoint translatedPoint = [panGesture translationInView:self];/*KXLY*/
  401. CGRect frame = controlBtn.frame;
  402. frame.origin.x = translatedPoint.x + startFrame.origin.x;
  403. frame.origin.y = translatedPoint.y + startFrame.origin.y;
  404. controlBtn.frame = frame;
  405. // HLog(@"\n--(%f,%f)--controlBtn.frame--X-%f",translatedPoint.x,translatedPoint.x,controlBtn.frame.origin.x);
  406. break;
  407. }
  408. case UIGestureRecognizerStateEnded:
  409. // HLog(@"云手机推流界面 控制按钮拖动手势结束");
  410. [[NSNotificationCenter defaultCenter] postNotificationName:PlayerViewControlBtnTouchEndNotification object:nil userInfo:nil];
  411. /*防止控制器移出屏幕*/
  412. CGRect frame = controlBtn.frame;
  413. if (frame.origin.x < 10.f/2.f){
  414. frame.origin.x = 10.f/2.f;
  415. }
  416. if (frame.origin.y < 10.f/2.f + H_STATE_BAR){
  417. frame.origin.y = 10.f/2.f + H_STATE_BAR;
  418. }
  419. if (frame.size.width + frame.origin.x + 10.f/2.f > self.width){
  420. frame.origin.x = self.width - 10.f/2.f - frame.size.width;
  421. }
  422. if (frame.size.height + frame.origin.y + 10.f/2.f > self.height){
  423. frame.origin.y = self.height - 10.f/2.f - frame.size.height;
  424. }
  425. controlBtn.frame = frame;
  426. break;
  427. case UIGestureRecognizerStateCancelled: {
  428. /*防止控制器移出屏幕*/
  429. CGRect frame = controlBtn.frame;
  430. if (frame.origin.x < 10.f/2.f){
  431. frame.origin.x = 10.f/2.f;
  432. }
  433. if (frame.origin.y < 10.f/2.f + H_STATE_BAR){
  434. frame.origin.y = 10.f/2.f + H_STATE_BAR;
  435. }
  436. if (frame.size.width + frame.origin.x + 10.f/2.f > self.width){
  437. frame.origin.x = self.width - 10.f/2.f - frame.size.width;
  438. }
  439. if (frame.size.height + frame.origin.y + 10.f/2.f > self.height){
  440. frame.origin.y = self.height - 10.f/2.f - frame.size.height;
  441. }
  442. controlBtn.frame = frame;
  443. break;
  444. }
  445. default:
  446. break;
  447. }
  448. }
  449. - (void)setIsLan:(BOOL)isLan{
  450. self->isLan = isLan;
  451. /*设置视图方向*/
  452. showImageView.isLan = isLan;
  453. touchCommondView.isLan = isLan;
  454. //[self setShowOrHideBottomButtonsFunBy:isLan];
  455. }
  456. - (void)setShowOrHideBottomButtonsFunBy:(BOOL)isHide
  457. {
  458. mainBlock(^{
  459. self->mueBtn.hidden = isHide;
  460. self->homeBtn.hidden = isHide;
  461. self->backBtn.hidden = isHide;
  462. });
  463. }
  464. #pragma mark 点击屏幕出来
  465. - (void)didTapBeganFun
  466. {
  467. if(!isLan){
  468. return;
  469. }
  470. // if(![commondStr containsString:@"\"count\":1"]){
  471. // return;
  472. // }
  473. if(mueBtn.hidden){
  474. [self setShowOrHideBottomButtonsFunBy:NO];
  475. KWeakSelf
  476. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  477. [weakSelf timerToHideBottomButtonFun];
  478. });
  479. }
  480. else{
  481. [self setShowOrHideBottomButtonsFunBy:YES];
  482. }
  483. }
  484. - (void)timerToHideBottomButtonFun
  485. {
  486. if(!isLan){
  487. return;
  488. }
  489. [self setShowOrHideBottomButtonsFunBy:YES];
  490. }
  491. - (void)getPlayerBottomNavShowOrHidefun
  492. {
  493. BOOL haveShowBottonNavType = ![HWDataManager getBoolWithKey:Consn_player_Nav_hide];
  494. if(haveShowBottonNavType){
  495. bottomContrView.hidden = NO;
  496. }
  497. else{
  498. bottomContrView.hidden = YES;
  499. }
  500. }
  501. @end