I'm trying to display a 3D stereo video in a googlevr app in a clean fashion, without showing the UI. I know about usability guidelines, but the device running the app will be always kept inside a viewer in a sort of demo, so no touch interaction expected.
I'm using a VrVideoView. So I already got rid of fullscreen button, info button, stereo mode button, google cardboard tutorial screen named "transition view" and touch tracking to move the view.
videoWidgetView.setFullscreenButtonEnabled(false);
videoWidgetView.setInfoButtonEnabled(false);
videoWidgetView.setStereoModeButtonEnabled(false);
videoWidgetView.setTransitionViewEnabled(false);
videoWidgetView.setTouchTrackingEnabled(false);
I also enabled fullscreen stereo by default.
videoWidgetView.setDisplayMode(VrWidgetView.DisplayMode.FULLSCREEN_STEREO);
But I can't remove the close button "x" and the option button.
I think that the "x" is fullscreenBackButton
of VrWidgetView
, parent of VrVideoView
. Which hasn't methods to control its visibility.
Is there a way to remove those two buttons?
Maybe subclassing and rewriting part of the widget code?
Maybe just a little hack putting a black overlay above those corners?
I've also tried as suggested
findViewById(R.id.ui_back_button).setVisibility(GONE);
or even
findViewById(com.google.vr.widgets.common.R.id.ui_back_button).setVisibility(GONE);
without success, they give:
NullPointerException: Attempt to invoke virtual method 'void android.view.View.setVisibility(int)' on a null object reference
For me this solution works.
It uses field functionality to get vrUiLayer
which is a private member of VrWidgetView which is the parent of VrVideoView.
Field f;
try {
f = this.videoWidgetView.getClass().getSuperclass().getDeclaredField("vrUiLayer");
f.setAccessible(true);
UiLayer vrLayer = (UiLayer) f.get(this.videoWidgetView);
// - here you can directly access to the UiLayer class - //
// to hide the up-right settings button
vrLayer.setSettingsButtonEnabled(false);
//setting listener to null hides the x button
vrLayer.setBackButtonListener(null);
// these visibility options are frequently updated when you play videos,
// so you have to call them often
// OR
vrLayer.setEnabled(false); // <- just hide the UI layer
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
Don't forget to import the class
import com.google.vr.cardboard.UiLayer
Beware that using vrLayer.setEnabled(false)
hides also the center line, leaving a complete clean vr experience.