123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- //
- // webRtcPlayerViewController+AdjustPlayerViewFrame.m
- // 双子星云手机
- //
- // Created by xd h on 2024/9/5.
- //
- #import "webRtcPlayerViewController+AdjustPlayerViewFrame.h"
- @implementation webRtcPlayerViewController (AdjustPlayerViewFrame)
- - (void)setPoMas_makeWithImageRate:(CGFloat)w_h_rate{
- /*播放视图*/
- // touchCommondView.isLan = NO;
- lastVideoWHRate = w_h_rate;
- BOOL fullScreenShow = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
- [self.mediaStream mas_remakeConstraints:^(MASConstraintMaker *make) {
- CGFloat scr_W = SCREEN_W;
- CGFloat scr_H = SCREEN_H;
- if (SCREEN_W > SCREEN_H){
- scr_W = SCREEN_H;
- scr_H = SCREEN_W;
- }
-
- if(fullScreenShow){//全屏
- make.left.mas_equalTo(0.f);
- make.right.mas_equalTo(0.f);
- make.bottom.mas_equalTo(0.f);
- make.top.mas_equalTo(0.f);
- }
- else{//非全屏
- if ((scr_H - scr_W/w_h_rate - 40.f) < 0){//空余高度不满 40 (宽不能满屏)
- make.height.mas_equalTo(scr_H - 40.f);
- make.width.mas_equalTo((scr_H - 40.f)*w_h_rate);
- make.centerX.equalTo(self.view.mas_centerX);
- make.top.mas_equalTo(0);
- }
- else if ((scr_H - scr_W/w_h_rate - 40.f*2) < 0){//空余高度不满 80 (Y不能居中)
- make.height.mas_equalTo(scr_H);
- make.width.mas_equalTo((scr_H)*w_h_rate);
- make.centerX.equalTo(self.view.mas_centerX);
- make.bottom.mas_equalTo(-40);
- }
- else{// 宽满屏 Y居中
- make.left.mas_equalTo(0.f);
- make.right.mas_equalTo(0.f);
- make.height.mas_equalTo(scr_W/w_h_rate);
- //make.top.mas_equalTo((scr_H - scr_W/w_h_rate - 40.f)/2.f);
- make.centerY.equalTo(self.view.mas_centerY);
- }
- }
-
- }];
-
- //[self.mediaStream setVideoContentMode:UIViewContentModeScaleAspectFit];
-
- [self.bottomContrView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(40.f);
- make.right.mas_equalTo(0.f);
- if(fullScreenShow){
- make.bottom.mas_equalTo(0);
- }
- else{
- make.top.equalTo(self.mediaStream.mas_bottom);
- }
- make.left.mas_equalTo(0.f);
- }];
- [self.bottomContrView updateFrameFunByIsLan:NO];
- }
- /**
- * @brief 设置横屏模式UI布局
- *
- * @param w_h_rate 宽高比
- */
- - (void)setLanMas_makeWithImageRate:(CGFloat)w_h_rate{
-
- lastVideoWHRate = w_h_rate;
- BOOL fullScreenShow = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
-
- CGFloat h_forPhoneBottomView = 40.0;
- CGFloat h_forPhoneTop = 0;
- if (IPHONE_X){
- h_forPhoneTop = 44.f;
- }
- // CGFloat des_W = SCREEN_W<SCREEN_H?SCREEN_W:SCREEN_H;/*实际较小的数字*/
- // CGFloat des_H = (SCREEN_W>SCREEN_H?SCREEN_W:SCREEN_H) - h_forPhoneTop;/*实际较大的数字*/
-
- // [self.mediaStream mas_remakeConstraints:^(MASConstraintMaker *make) {
- // make.bottom.mas_equalTo(0.f);
- // make.width.mas_equalTo(des_W*w_h_rate);
- // make.left.mas_equalTo(h_forPhoneTop + (des_H - h_forPhoneBottomView - des_W*w_h_rate)/2.f);
- // make.top.mas_equalTo(0);
- // }];
-
- [self.mediaStream mas_remakeConstraints:^(MASConstraintMaker *make) {
- CGFloat scr_W = SCREEN_W;
- CGFloat scr_H = SCREEN_H;
- if (SCREEN_W < SCREEN_H){
- scr_W = SCREEN_H;
- scr_H = SCREEN_W;
- }
-
- if(fullScreenShow){//全屏
- make.left.mas_equalTo(0.f);
- make.right.mas_equalTo(0.f);
- make.bottom.mas_equalTo(0.f);
- make.top.mas_equalTo(0.f);
- }
- else{//非全屏
- if ((scr_W - scr_H*w_h_rate - 40.f) < 0){//空余宽度不满 40 (高不能满屏)
- make.height.mas_equalTo((scr_W - 40.f)/w_h_rate);
- make.width.mas_equalTo(scr_W - 40.f);
- make.centerX.equalTo(self.view.mas_centerX);
- make.left.mas_equalTo(0);
- }
- else if ((scr_W - scr_H*w_h_rate - 40.f*2) < 0){//空余宽度不满 80 (X不能居中)
- make.height.mas_equalTo(scr_H);
- make.width.mas_equalTo((scr_H)*w_h_rate);
- make.centerY.equalTo(self.view.mas_centerX);
- make.right.mas_equalTo(-40);
- }
- else{// 高满屏 X居中
- make.height.mas_equalTo(scr_H);
- make.top.mas_equalTo(0.f);
- make.width.mas_equalTo(scr_H*w_h_rate);
- make.centerX.equalTo(self.view.mas_centerX);
- }
- }
-
- }];
-
-
-
- [self.bottomContrView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(h_forPhoneBottomView);
- if(fullScreenShow){
- make.right.mas_equalTo(0);
- }
- else{
- make.left.equalTo(self.mediaStream.mas_right);
- }
- make.top.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
- [self.bottomContrView updateFrameFunByIsLan:YES];
- }
- @end
|