<u id="rnvt2"><dl id="rnvt2"></dl></u>

            1. <mark id="rnvt2"></mark>
            <source id="rnvt2"></source><u id="rnvt2"><sub id="rnvt2"></sub></u>

            1. <u id="rnvt2"><small id="rnvt2"></small></u>

            2. <u id="rnvt2"></u>
            3. 幫助與文檔
              熱搜關鍵詞:直播系統短視頻源碼一對一
              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.radissonsedona.com

              本文標簽: 直播商城源碼
              男人和女人高潮免费网站_国产熟女高潮视频_精品国产美女福到在线不卡_japanese日本护士xxx