webRtcPlayerViewController+AdjustPlayerViewFrame.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // webRtcPlayerViewController+AdjustPlayerViewFrame.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/9/5.
  6. //
  7. #import "webRtcPlayerViewController+AdjustPlayerViewFrame.h"
  8. @implementation webRtcPlayerViewController (AdjustPlayerViewFrame)
  9. - (void)setPoMas_makeWithImageRate:(CGFloat)w_h_rate{
  10. /*播放视图*/
  11. // touchCommondView.isLan = NO;
  12. lastVideoWHRate = w_h_rate;
  13. BOOL fullScreenShow = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
  14. [self.mediaStream mas_remakeConstraints:^(MASConstraintMaker *make) {
  15. CGFloat scr_W = SCREEN_W;
  16. CGFloat scr_H = SCREEN_H;
  17. if (SCREEN_W > SCREEN_H){
  18. scr_W = SCREEN_H;
  19. scr_H = SCREEN_W;
  20. }
  21. if ((scr_H - scr_W/w_h_rate - 40.f)/2.f < 0){
  22. if(fullScreenShow){
  23. make.height.mas_equalTo(scr_H);
  24. make.width.mas_equalTo(scr_W);
  25. }
  26. else{
  27. make.height.mas_equalTo(scr_H - 40.f);
  28. make.width.mas_equalTo((scr_H - 40.f)*w_h_rate);
  29. }
  30. make.centerX.equalTo(self.view.mas_centerX);
  31. make.top.mas_equalTo(0);
  32. }
  33. else{
  34. make.left.mas_equalTo(0.f);
  35. make.right.mas_equalTo(0.f);
  36. if(fullScreenShow){
  37. make.height.mas_equalTo(scr_H);
  38. make.top.mas_equalTo(0.f);
  39. }
  40. else{
  41. make.height.mas_equalTo(scr_W/w_h_rate);
  42. make.top.mas_equalTo((scr_H - scr_W/w_h_rate - 40.f)/2.f);
  43. }
  44. }
  45. }];
  46. [self.bottomContrView mas_remakeConstraints:^(MASConstraintMaker *make) {
  47. make.height.mas_equalTo(40.f);
  48. make.right.equalTo(self.mediaStream.mas_right);
  49. if(fullScreenShow){
  50. make.bottom.mas_equalTo(0);
  51. }
  52. else{
  53. make.top.equalTo(self.mediaStream.mas_bottom);
  54. }
  55. make.left.equalTo(self.mediaStream.mas_left);
  56. }];
  57. [self.bottomContrView updateFrameFunByIsLan:NO];
  58. }
  59. /**
  60. * @brief 设置横屏模式UI布局
  61. *
  62. * @param w_h_rate 宽高比
  63. */
  64. - (void)setLanMas_makeWithImageRate:(CGFloat)w_h_rate{
  65. lastVideoWHRate = w_h_rate;
  66. BOOL fullScreenShow = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
  67. CGFloat h_forPhoneBottomView = 40.0;
  68. CGFloat h_forPhoneTop = 0;
  69. if (IPHONE_X){
  70. h_forPhoneTop = 44.f;
  71. }
  72. CGFloat des_W = SCREEN_W<SCREEN_H?SCREEN_W:SCREEN_H;/*实际较小的数字*/
  73. CGFloat des_H = (SCREEN_W>SCREEN_H?SCREEN_W:SCREEN_H) - h_forPhoneTop;/*实际较大的数字*/
  74. [self.mediaStream mas_remakeConstraints:^(MASConstraintMaker *make) {
  75. make.bottom.mas_equalTo(0.f);
  76. make.width.mas_equalTo(des_W*w_h_rate);
  77. make.left.mas_equalTo(h_forPhoneTop + (des_H - h_forPhoneBottomView - des_W*w_h_rate)/2.f);
  78. make.top.mas_equalTo(0);
  79. }];
  80. [self.bottomContrView mas_remakeConstraints:^(MASConstraintMaker *make) {
  81. make.width.mas_equalTo(h_forPhoneBottomView);
  82. make.left.equalTo(self.mediaStream.mas_right);
  83. if(fullScreenShow){
  84. make.right.mas_equalTo(0);
  85. }
  86. else{
  87. make.top.mas_equalTo(0);
  88. }
  89. make.bottom.mas_equalTo(0);
  90. }];
  91. [self.bottomContrView updateFrameFunByIsLan:YES];
  92. }
  93. @end