@Override public void onHideCustomView() { // This method should be manually called on video end in all cases because it's not always // called automatically. // This method must be manually called on back key press (from this class' onBackPressed() // method). if (isVideoFullscreen) { showActionBar(); activityNonVideoView.setVideoPlaying(false); // Hide the video view, remove it, and show the non-video view ViewGroup activityVideoView = ((ViewGroup) MainActivity.webLayout.findViewById(R.id.webviewholder)); activityVideoView.removeView(videoViewContainer); activityNonVideoView.setVisibility(View.VISIBLE); // Call back (only in API level <19, because in API level 19+ with chromium webview it // crashes) if (videoViewCallback != null && !videoViewCallback.getClass().getName().contains(".chromium.")) { videoViewCallback.onCustomViewHidden(); } // Reset video related variables isVideoFullscreen = false; videoViewContainer = null; videoViewCallback = null; // Notify full-screen change if (toggledFullscreenCallback != null) { toggledFullscreenCallback.toggledFullscreen(false); } } }