Source:
private void setupInlineVideoView(String inlineVideoURI) { if (inlineVideoURI == null) { return; } try { final String videoFilename = ReferenceManager.instance().DeriveReference(inlineVideoURI).getLocalURI(); final File videoFile = new File(videoFilename); if (!videoFile.exists()) { showMissingMediaView(inlineVideoURI, StringUtils.getStringRobust(getContext(), R.string.video_download_prompt), true, () -> { hideMissingMediaView(); setupInlineVideoView(inlineVideoURI); }); } else { final CommCareMediaController ctrl = new CommCareMediaController(this.getContext()); ctrl.setId(AndroidUtil.generateViewId()); videoView.setOnPreparedListener(mediaPlayer -> { FrameLayout frameLayout = (FrameLayout)ctrl.getParent(); ((ViewGroup)frameLayout.getParent()).removeView(frameLayout); ConstraintLayout.LayoutParams params = new Constraints.LayoutParams(LayoutParams.MATCH_CONSTRAINT, LayoutParams.WRAP_CONTENT); params.bottomToBottom = videoView.getId(); params.leftToLeft = videoView.getId(); params.rightToRight = videoView.getId(); int margin = this.getResources().getDimensionPixelSize(R.dimen.question_widget_side_padding); params.leftMargin = margin; params.rightMargin = margin; ((ConstraintLayout)videoView.getParent()).addView(frameLayout, params); ctrl.setAnchorView(videoView); videoView.setMediaController(ctrl); ctrl.show(); }); makeVideoViewVisible(); videoView.setVideoPath(videoFilename); videoView.setListener(duration -> { if (duration == 0) { return; } FirebaseAnalyticsUtil.reportInlineVideoPlayEvent(videoFilename, FileUtil.getDuration(videoFile), duration); }); videoView.setOnClickListener(v -> ViewUtil.hideVirtualKeyboard((Activity)getContext())); videoView.setVisibility(VISIBLE); } } catch (InvalidReferenceException ire) { Log.e(TAG, "invalid video reference exception"); ire.printStackTrace(); showMissingMediaView(inlineVideoURI, "Invalid reference: " + ire.getReferenceString(), false, null); } }

Target:
private void setupInlineVideoView(String inlineVideoURI) { try { final String videoFilename = ReferenceManager.instance().DeriveReference(inlineVideoURI).getLocalURI(); final File videoFile = new File(videoFilename); if (!videoFile.exists()) { showMissingMediaView(inlineVideoURI, StringUtils.getStringRobust(getContext(), R.string.video_download_prompt), true, () -> { setupInlineVideoView(inlineVideoURI); }); } else { final CommCareMediaController ctrl = new CommCareMediaController(this.getContext()); ctrl.setId(AndroidUtil.generateViewId()); videoView.setOnPreparedListener(mediaPlayer -> { FrameLayout frameLayout = (FrameLayout)ctrl.getParent(); ((ViewGroup)frameLayout.getParent()).removeView(frameLayout); ConstraintLayout.LayoutParams params = new Constraints.LayoutParams(LayoutParams.MATCH_CONSTRAINT, LayoutParams.WRAP_CONTENT); params.bottomToBottom = videoView.getId(); params.leftToLeft = videoView.getId(); params.startToStart = videoView.getId(); params.rightToRight = videoView.getId(); params.endToEnd = videoView.getId(); int margin = this.getResources().getDimensionPixelSize(R.dimen.question_widget_side_padding); params.leftMargin = margin; params.rightMargin = margin; ((ConstraintLayout)videoView.getParent()).addView(frameLayout, params); ctrl.setAnchorView(videoView); videoView.setMediaController(ctrl); ctrl.show(); }); makeVideoViewVisible(); videoView.setVideoPath(videoFilename); videoView.setListener(duration -> { if (duration == 0) { return; } FirebaseAnalyticsUtil.reportInlineVideoPlayEvent(videoFilename, FileUtil.getDuration(videoFile), duration); }); videoView.setOnClickListener(v -> ViewUtil.hideVirtualKeyboard((Activity)getContext())); videoView.setVisibility(VISIBLE); } } catch (InvalidReferenceException ire) { Log.e(TAG, "invalid video reference exception"); ire.printStackTrace(); showMissingMediaView(inlineVideoURI, Localization.get("media.missing.invalid.reference", ire.getReferenceString()), false, null); } }