Ejemplo n.º 1
0
  /**
   * 具体的转屏执行函数--使用父窗口方式
   *
   * @param container
   * @param isFullScreen
   */
  private void setIsFullModeUsingContainer(ViewGroup container, boolean isFullScreen) {
    if (container == null) {
      VDLog.e(VDVideoFullModeController.TAG, "videoview---setIsFullMode---container--return null");
      throw new IllegalArgumentException("container is null");
    }
    if (mVideoViewParams == null) {
      VDLog.e(
          VDVideoFullModeController.TAG,
          "videoview---setIsFullMode---mVideoViewParams--return null");
      mVideoViewParams = getLayoutParams();
    }
    mVideoView.beginChangeParentView();

    if (mVideoFullScreenContainer != null) {
      mVideoFullScreenContainer.removeAllViews();
    }

    if (mVideoFullScreenContainer.getParent() == null) {
      changeToRoot(mVideoFullScreenContainer);
    }
    VDVideoViewController controller = VDVideoViewController.getInstance(mContext);
    if (controller != null) {
      controller.notifyScreenOrientationSwitch(isFullScreen);
      if (mVideoView.isPlaying()) {
        controller.notifyOnShowHideADContainer(true);
      }
    }
    if (isFullScreen) {
      if (mExternalFullScreenContainer != null) {
        mExternalFullScreenContainer.setVisibility(VISIBLE);
      }
      // 横屏
      VDVideoScreenOrientation.setStatusBarVisible(mContext, true);
      mVideoFullScreenContainer.setVisibility(View.VISIBLE);

      container.removeView(this);
      mVideoFullScreenContainer.addView(
          this, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    } else {
      if (mExternalFullScreenContainer != null) {
        mExternalFullScreenContainer.setVisibility(GONE);
      }
      VDVideoScreenOrientation.setStatusBarVisible(mContext, false);
      mVideoFullScreenContainer.setVisibility(View.GONE);
      // 竖屏
      if (getParent() == null) {
        container.addView(this, mVideoViewParams);
      }
    }
    for (VDVideoViewLayerContext item : mVDVideoViewLayerData.getLayerList()) {
      if (item.mIsComplexLayerType) {
        // 有复杂模式才进行横竖屏转换
        if (controller != null) item.setFullMode(isFullScreen, controller.isInsertAD());
      }
    }
    mVideoView.endChangeParentView();
    mVideoView.requestVideoLayout();
  }
Ejemplo n.º 2
0
  /**
   * 增加一个私有函数,用来做initVideo时候的调用专用
   *
   * @param isFullScreen
   * @param isInited
   */
  private void setIsFullScreen(boolean isFullScreen, boolean isInited) {
    if (mVDVideoViewContainer == null) {
      VDLog.e(
          VDVideoFullModeController.TAG,
          "videoview---setIsFullScreen---mVDVideoViewContainer--return null");
      return;
    }

    if (mVDVideoViewLayerData.getLayerType()
        == VDVideoViewLayerContextData.LAYER_COMPLEX_NOVERTICAL) {
      // 只横不竖方式,不允许转屏
      VDVideoFullModeController.getInstance().setFullLock();
      VDVideoScreenOrientation.setOnlyLandscape(mContext);
      isFullScreen = true;
    }

    // 设置当前的转屏方式
    setIsFullModeUsingContainer(mVDVideoViewContainer, isFullScreen);
    if (VDVideoFullModeController.getInstance().mInHandNum == 1) {
      VDVideoFullModeController.getInstance().setIsManual(false);
    }
    if (VDVideoFullModeController.getInstance().getIsFromHand()) {
      VDVideoFullModeController.getInstance().mInHandNum++;
    }
    VDVideoFullModeController.getInstance().setIsFullScreen(isFullScreen);

    if (!isInited) {
      // 回调接口,实现相应的横竖屏转换通知
      VDVideoViewController cnotroller = VDVideoViewController.getInstance(mContext);
      if (cnotroller != null)
        cnotroller.notifyFullScreen(
            isFullScreen, VDVideoFullModeController.getInstance().getIsFromHand());
    }
  }
Ejemplo n.º 3
0
 /** 初始化屏幕部分,保证横屏进入正常 */
 public void initVideo() {
   // 全屏容器
   boolean isFullScreen = false;
   // @sunxiao1 modify ,加入只横不竖方式,直接横屏设置过去
   if (VDVideoScreenOrientation.getIsLandscape(mContext)
       || mVDVideoViewLayerData.getLayerType()
           == VDVideoViewLayerContextData.LAYER_COMPLEX_NOVERTICAL) {
     isFullScreen = true;
   }
   setIsFullScreen(isFullScreen, true);
   VDVideoFullModeController.getInstance().setIsFullScreen(isFullScreen);
   // 设置音量部分
   for (VDVideoViewLayerContext context : mVDVideoViewLayerData.getLayerList()) {
     if (context.checkSoundWidget()) {
       VDVideoViewController controller = VDVideoViewController.getInstance(mContext);
       if (controller != null) controller.mIsHasSoundWidget = true;
       break;
     }
   }
 }