小班直播

提示:具体的调用方式可参考Demo 中的LiveRtcActivity类

视图布局


添加白板视图
<com.talkfun.whiteboard.view.CloudWhiteBoardView
    android:id="@+id/white_board"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

初始化直播


  • 创建直播逻辑实例

     LiveRtcPresenterImpl  mLiveRtcPresenterImpl = new                 
     LiveRtcPresenterImpl(mContext,onRtcMemberListener);
               mLiveRtcPresenterImpl.setLiveListener(this);
               mLiveRtcPresenterImpl.setRtcMediaStatusListener(this);
               mLiveRtcPresenterImpl.setRtcStatusListener(this);
               mLiveRtcPresenterImpl.setWhiteboardPowerListener(this);
               mLiveRtcPresenterImpl.setRtcErrorListener(this);
               mLiveRtcPresenterImpl.setLiveDurationListener(this);
               mLiveRtcPresenterImpl.setWhiteboardRecoverListener(this);
               mWhiteBoardPresenter = new WhiteBoardPresenterImpl();
               mWhiteBoardPresenter.setWhiteboardView(pptContainer);
               mLiveRtcPresenterImpl.setWhiteBoardPresenter(mWhiteBoardPresenter);
    注释:LiveRtcPresenterImpl具体的调用细则请参考LiveRtcPresenterImpl类

文档列表逻辑、聊天逻辑


  • 初始化文档列表逻辑
      //实例化文档、图片加载逻辑对象
      IDocument.DocumentPresenter presenter;
      presenter = new DocumentPresenterImpl(mContext);
      //加载文档列表数据
      presenter.getDocumentList(new IDocument.GetDocumentListCallback() {
      @Override
      public void onGetDocuments(List<DocDataBean> list) {
      //获取文档列表回调,如果没文档数据list为空
          if(list != null){
              ...
          }
      }
      });
      //加载本地图片数据
      presenter.getPictureBucketList(new IDocument.GetDevicePictureBucketsCallback() {
      @Override
      public void onGetDevicePictureBuckets(List<DevicePictureBucket> list) {
              if(list != null){
                  ...
              }
          }
      });
  • 初始化聊天逻辑
IChat.ChatPresenter presenter;
presenter = new ChatPresenterImpl();
  • 初始化文件传输对象
IFileTransfer.Presenter mFileTransfer;
mFileTransfer = new FileTransferPresenterImpl();
  • 载入文档资源

     mFileTransfer.loadDocRes(docDetailData, new IFileTransfer.LoadDocDataCallback() {

            @Override
            public void onLoadDocDataProgress(String progress) {

            }

            @Override
            public void onLoadDocDataSuccess(DocumentInfoBean data) {

            }

            @Override
            public void onLoadDocDataFail(int code,String msg) {

            }
        });
  • 上传选中图片资源--插入图片
      mFileTransfer.uploadImagesByUri(context,selectImageList, new IFileTransfer.UpdateImageCallback() {
            @Override
            public void onUploadImageProgress(int progress) {

            }

            @Override
            public void onUploadImageFail(String msg) {

            }

            @Override
            public void onUploadImageSuccess(List<UploadDocDataBean> dataList) {

            }
        });

开始直播


    //开始直播,申请直播
     mLiveRtcPresenterImpl.startLive();

        //开始直播成功回调
    public void onStartLiveSuccess() {
        setIsLiving(true);
        whiteBoardFragment.preToStart(this);
        if (mIsStart) {
        showLiveStatusTip(UIUtil.getString(R.string.start_live_success));
        }
    }

     /**
      * 开始直播失败回调
      */
     @Override
     public void onStartLiveFail(String error) {
        ivStartOrStop.setImageResource(R.mipmap.btn_start_live);
        mIsLiving = false;
        mIsStart = false;
          showLiveStatusTip(UIUtil.getString(R.string.start_live_fail));
      }
   //开启连麦上讲台功能
   mLiveRtcPresenterImpl.startRtc();

  //关闭连麦上讲台功能
  mLiveRtcPresenterImpl.stopRtc();

结束直播


//结束直播
mLiveRtcPresenterImpl.stopLive();

生命周期方法


在Activity的onResume()、onPause()、onDestroy()方法中调用相应方法

     @Override
    protected void onResume() {
        super.onResume();
        mLiveInPresenterImpl.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mLiveInPresenterImpl.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mLiveInPresenterImpl.onDestroy();
    }

results matching ""

    No results matching ""