@Override
  public void onShowCustomView(View view, CustomViewCallback callback) {
    super.onShowCustomView(view, callback);
    // Android SDK版本
    if (Build.VERSION.SDK_INT >= 14) {

      if (view instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) view; // A video wants to be shown
        View focusedChild = frameLayout.getFocusedChild();
        this.isVideoFullscreen = true;
        this.videoViewContainer = frameLayout;
        this.videoViewCallback = callback;
        activityNonVideoView.setVisibility(View.GONE); // 隐藏掉视频所在布局中除了用来展示全屏视频以外的布局
        activityVideoView.addView(
            videoViewContainer,
            new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        activityVideoView.setVisibility(View.VISIBLE); // 设置全屏布局可见
        ((Activity) activityVideoView.getContext())
            .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // 强制当前页面在手机中横屏
        if (focusedChild instanceof VideoView) { // VideoView (typically API level <11)
          VideoView videoView = (VideoView) focusedChild;
          videoView.setOnPreparedListener(this); // Handle all the required events
          videoView.setOnCompletionListener(this);
          videoView.setOnErrorListener(this);
        } else {
          // Usually android.webkit.HTML5VideoFullScreen$VideoSurfaceView, sometimes
          // android.webkit.HTML5VideoFullScreen$VideoTextureView
          // HTML5VideoFullScreen (typically API level 11+)
          // Handle HTML5 video ended event
          if (webView != null && webView.getSettings().getJavaScriptEnabled()) {
            // Run javascript code that detects the video end and notifies the interface
            String js = "javascript:";
            js += "_ytrp_html5_video = document.getElementsByTagName('video')[0];";
            js += "if (_ytrp_html5_video !== undefined) {";
            {
              js += "function _ytrp_html5_video_ended() {";
              {
                js += "_ytrp_html5_video.removeEventListener('ended', _ytrp_html5_video_ended);";
                js +=
                    "_VideoEnabledWebView.notifyVideoEnd();"; // Must match Javascript interface
                                                              // name and method of
                                                              // VideoEnableWebView
              }
              js += "}";
              js += "_ytrp_html5_video.addEventListener('ended', _ytrp_html5_video_ended);";
            }
            js += "}";
            webView.loadUrl(js);
          }
        }

        // Notify full-screen change
        if (toggledFullscreenCallback != null) {
          toggledFullscreenCallback.toggledFullscreen(true);
        }
      }
    }
  }
 @Override
 public void onShowCustomView(View view, CustomViewCallback cb) {
   TraceEvent.begin();
   if (mWebChromeClient != null) {
     if (TRACE) Log.d(TAG, "onShowCustomView");
     mWebChromeClient.onShowCustomView(view, cb);
   }
   TraceEvent.end();
 }
예제 #3
0
    public void onShowCustomView(View var1, CustomViewCallback var2) {
      if (VERSION.SDK_INT >= 14) {
        if (CRWebViewFragment.this.mCustomView != null) {
          var2.onCustomViewHidden();
          return;
        }

        this.mOriginalOrientation = this.mActivity.getRequestedOrientation();
        FrameLayout var3 = (FrameLayout) this.mActivity.getWindow().getDecorView();
        this.mFullscreenContainer = new CRWebViewFragment.FullscreenHolder(this.mActivity);
        this.mFullscreenContainer.addView(var1, this.COVER_SCREEN_PARAMS);
        var3.addView(this.mFullscreenContainer, this.COVER_SCREEN_PARAMS);
        CRWebViewFragment.this.mCustomView = var1;
        this.setFullscreen(true);
        CRWebViewFragment.this.mCustomViewCallback = var2;
      }

      super.onShowCustomView(var1, var2);
    }
 @Override
 public void onShowCustomView(View view, CustomViewCallback callback) {
   if (originalWebChromeClient != null) {
     originalWebChromeClient.onShowCustomView(view, callback);
   }
 }
예제 #5
0
 @Override
 public void onShowCustomView(View view, CustomViewCallback callback) {
   super.onShowCustomView(view, callback);
 }