/** * 具体的转屏执行函数--使用父窗口方式 * * @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(); }
/** * 增加一个私有函数,用来做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()); } }
@Override public void onPreOpenDLNA() { VDVideoViewController contoller = VDVideoViewController.getInstance(mContext); VDVideoInfo mVideoInfo = null; if (contoller != null) mVideoInfo = contoller.getCurrentVideo(); VDLog.i("DLNA", "onPreOpenDLNA " + mVideoInfo.mTitle); if (mVideoInfo != null) { if (mVideoInfo.mIsLive) { DLNAController.getInstance(getContext()).mPlayUrl = mVideoInfo.getVideoUrl(VDSharedPreferencesUtil.getCurResolution(mContext)); } else { if (VDUtility.isLocalUrl(mVideoInfo.mPlayUrl)) { // 解析 DLNAController.getInstance(getContext()).mPlayUrl = mVideoInfo.getNetUrl(); } else { DLNAController.getInstance(getContext()).mPlayUrl = (mVideoInfo.mRedirectUrl == null ? mVideoInfo.mPlayUrl : mVideoInfo.mRedirectUrl); } } DLNAController.getInstance(getContext()).open(); } }