PlayerView.m 21 KB

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