1. <tbody id="02xsg"></tbody>
        2. <em id="02xsg"><tr id="02xsg"><u id="02xsg"></u></tr></em>
          1. 
            
              帮助与文档
              热搜关键词:直播系统短视频源码一对一
              Ios端直播商城源码开发之实现全屏直播功能
              发布来源:云豹科技    发布人:云豹科技    Date:2022-02-21 10:01:04

              直播商城源码是以直播带货为核心的直播平台,实现了互动连麦、礼物打赏、主播PK、直播评论等直播相关内容,同时还实现了短视频、电商商城、动态广场等功能。今天,我们就直播功能进行分析,看看直播商城源码如何实现直播间全屏播放功能,以及点击全屏播放保留头像、关注按钮,关闭恢复原来直播间功能。

              1. 点击全屏创建播放的view并做旋转,传入直播间信息、推流信息


              -(void)fullScreenBtnClick{
                  if ([[Config getOwnID] intValue] <= 0) {
                      [[YBToolClass sharedInstance]waringLogin];
                      return;
                  }
                  YBWeakSelf;
                  if (!_fullscreenView) {
                      if ([_sdkType isEqual:@"1"]) {
                          [_txLivePlayer setMute:YES];
                      }else{
                          _js_player.shouldMute = YES;
                      }
                      isFullBool = YES;
                      _fullscreenView = [[FullScreenPlayView alloc]initWithFrame:CGRectMake(0, 0, _window_height, _window_width) withType:_sdkType andPlayDic:self.playDoc];
                      _fullscreenView.center = self.view.center;
                      _fullscreenView.btnEvent = ^(NSString *str) {
                          if ([str isEqual:@"hide"]) {
                              [weakSelf returnBtnClick];
                          }else if ([str isEqual:@"focus"]){
                              [weakSelf guanzhuZhuBolela];
                          }
                      };
                      [self.view addSubview:_fullscreenView];
                      
                      [_fullscreenView setFousBtnHide:setFrontV.newattention.hidden];
                      _fullscreenView.transform = CGAffineTransformMakeRotation((90.0f * M_PI) / 180.0f);
                      if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
                            // iOS 7
                            [self prefersStatusBarHidden];
                            [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
                        }
                  }
              }


              2. 绘制直播带货源码的播放界面、创建播放器监听推流信息,添加手势、进入播放5秒隐藏主播信息、关注按钮等信息,点击屏幕显示主播信息、关注按钮


              -(instancetype)initWithFrame:(CGRect)frame withType:(NSString *)sdkType andPlayDic:(NSDictionary *)playDic
              {
                  self = [super initWithFrame:frame];
                  if (self) {
                      UITapGestureRecognizer *tipsGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tipClick)];
                      [self addGestureRecognizer:tipsGesture];
                      
                      self.playDoc = playDic;
                      self.backgroundColor = UIColor.whiteColor;
                      returnBtn = [UIButton buttonWithType:0];
                      [returnBtn setImage:[UIImage imageNamed:@"personBack"] forState:0];
                      [returnBtn addTarget:self action:@selector(returnBtnClick) forControlEvents:UIControlEventTouchUpInside];
                      [self addSubview:returnBtn];
                      [returnBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                          make.left.equalTo(self.mas_left).offset(30+ShowDiff);
                          make.top.equalTo(self.mas_top).offset(20);
                          make.width.height.mas_equalTo(30);
                      }];
                      
                      nameLb = [[UILabel alloc]init];
                      nameLb.font = [UIFont systemFontOfSize:14];
                      nameLb.textColor = UIColor.whiteColor;
                      nameLb.text = minstr([playDic valueForKey:@"user_nicename"]);
                      [self addSubview:nameLb];
                      [nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
                          make.left.equalTo(returnBtn.mas_right).offset(10);
                          make.centerY.equalTo(returnBtn.mas_centerY);
                      }];
                      [self layoutIfNeeded];
                      //关注主播
                      _focusBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                      _focusBtn.frame = CGRectMake(nameLb.right+10,5,40,25);
                      _focusBtn.centerY = nameLb.centerY;
                      _focusBtn.layer.masksToBounds = YES;
                      _focusBtn.layer.cornerRadius = 12.5;
                      _focusBtn.titleLabel.font = [UIFont systemFontOfSize:11];
                      [_focusBtn setTitle:YZMsg(@"关注") forState:UIControlStateNormal];
                      _focusBtn.contentMode = UIViewContentModeScaleAspectFit;
                      [_focusBtn addTarget:self action:@selector(guanzhuzhubo) forControlEvents:UIControlEventTouchUpInside];
                      _focusBtn.hidden = YES;
                      [_focusBtn setBackgroundImage:[UIImage imageNamed:@"startLive_back"]];
                      [self addSubview:_focusBtn];
               
                      if ([sdkType isEqual:@"1"]) {
                          [self txPlayer];
                      }else{
                          [self jsPlayer];
                      }
                      [self  hideAllBtn];
                  }
                  return self;
              }


              3. 隐藏主播信息


              -(void)hideAllBtn{
                  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                      [UIView animateWithDuration:0.5 animations:^{
                          CGRect returnBtnFrame = returnBtn.frame;
                          returnBtnFrame.origin.y = -50;
                          returnBtn.frame = returnBtnFrame;
               
                          nameLb.centerY = returnBtn.centerY;
                          _focusBtn.centerY = returnBtn.centerY;
                      }];
                  });
               
              }


              4. 显示主播信息


              -(void)tipClick{
                  [UIView animateWithDuration:0.5 animations:^{
                          CGRect returnBtnFrame = returnBtn.frame;
                          returnBtnFrame.origin.y = 20;
                          returnBtn.frame = returnBtnFrame;
               
                          nameLb.centerY = returnBtn.centerY;
                          _focusBtn.centerY = returnBtn.centerY;
               
                      } completion:^(BOOL finished) {
                          if (finished) {
                              [self hideAllBtn];
                          }
                      }];
               
              }


              5. 点击返回后用block返回关闭标识并移除播放页面,恢复直播商城源码的原有直播间播放信息界面


              -(void)returnBtnClick{
                  if (self.btnEvent) {
                      self.btnEvent(@"hide");
                  }
              }


              6. /播放监听事件


              -(void) onPlayEvent:(int)EvtID withParam:(NSDictionary*)param {
              //    NSLog(@"eventID:%d===%@",EvtID,param);
                  dispatch_async(dispatch_get_main_queue(), ^{
                      if (EvtID == PLAY_EVT_CONNECT_SUCC) {
                          NSLog(@"moviplay不连麦已经连接服务器");
                      }
                      else if (EvtID == PLAY_EVT_RTMP_STREAM_BEGIN){
                          NSLog(@"moviplay不连麦已经连接服务器,开始拉流");
                      }
                      else if (EvtID == PLAY_EVT_PLAY_BEGIN){
                          NSLog(@"moviplay不连麦视频播放开始");
                          dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                          });
                      }
                      else if (EvtID== PLAY_WARNING_VIDEO_PLAY_LAG){
                          NSLog(@"moviplay不连麦当前视频播放出现卡顿(用户直观感受)");
                      }
                      else if (EvtID == PLAY_EVT_PLAY_END){
                          NSLog(@"moviplay不连麦视频播放结束");
                          [_txLivePlayer resume];
                      }
                      else if (EvtID == PLAY_ERR_NET_DISCONNECT) {
                          //视频播放结束
                          NSLog(@"moviplay不连麦网络断连,且经多次重连抢救无效,可以放弃治疗,更多重试请自行重启播放");
                      }else if (EvtID == PLAY_EVT_CHANGE_RESOLUTION) {
                          NSLog(@"主播连麦分辨率改变");
                      }
                  });
              }


              本文就直播商城源码如何实现直播间全屏播放等一系列功能,进行了简单介绍,如果有类似功能实现的需求,可以进行参照。如果想了解更多直播商城源码开发合作相关内容,可以查看官网页面。

              声明:以上内容为云豹科技原创,未经作者本人同意,禁止转载,否则将追究相关法律责任www.dosweyes.com

              本文标签: 直播商城源码
              久久亚洲天天做日日做_强行挺进少妇紧窄湿润_国产美女露脸口爆吞精_yellow的视频播放