如何在VrVideoView的Displaymode(3)中强制点击X(close, back button)?

How to force to click X(close, back button) in Displaymode (3) of VrVideoView?

我正在使用 VrVideoView 制作 VR Android 应用程序。我想在视频播放后强制点击 "close(X, back button)"。也就是我想在视频播放完后return到MainActivity。以下是我试过的代码。但是,我在视频播放完后并没有返回MainActivity。如果你知道怎么做,请告诉我。

1.

videoWidgetView.pauseVideo();
videoWidgetView.seekTo(0);
videoWidgetView.shutdown();

2.

videoWidgetView.pauseVideo();
videoWidgetView.seekTo(0);
finishActivity(0);

3.

videoWidgetView.pauseVideo();
videoWidgetView.seekTo(0);
findViewById(R.id.ui_back_button).performClick();

4.

videoWidgetView.pauseVideo();
videoWidgetView.seekTo(0);
Field f;

try {

     f =videoWidgetView.getClass().getSuperclass().getDeclaredField("vrUiLayer");
     f.setAccessible(true);
     UiLayer vrLayer = (UiLayer) f.get(videoWidgetView);

     vrLayer.getView().findViewById(R.id.ui_back_button).performClick();

} 
catch (NoSuchFieldException e) {
      e.printStackTrace();
} 
catch (IllegalAccessException e) {
   e.printStackTrace();
}

只需覆盖 OnDestroy 方法并将这些行添加到其中:

@Override
protected void onDestroy() {
    videoWidgetView.shutdown();
    super.onDestroy();
}

然后在onCompletion方法中调用onDestroy()方法:

    @Override
    public void onCompletion() {
        videoWidgetView.seekTo(0);
        videoWidgetView.pauseVideo();
        onDestroy();
    }

希望有用:)