Class PlayerView360

  • All Implemented Interfaces:
    Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, ViewManager, ViewParent, IPlayerView

    public class PlayerView360
    extends PlayerView
    The CastLabs PlayerView360 is a custom view that provides the video playback surface to render 360 degree video.

    You can add this view to an activity and access the PlayerController to gain control over the player.

    This view can also be used in conjunction with the GvrActivity's GvrActivity.setGvrView(GvrView) method given the getGvrView() method. The default rendering mode for this view is *mono*. If you want to render in stereo mode call setStereoModeEnabled(boolean) with true.

    Note that the view needs to react to certain activity lifecycle events to be able to start, stop, and resume playback when the activity is paused or resumed. The underlying PlayerController also needs to be shut down when the hosting activity is destroyed.

    The view offers a lifecycle helper class (see PlayerViewLifecycleDelegate) to simplify the integration, but you will need to hook up the events in the hosting activity. For this, overwrite the following methods in the hosting activity and delegate to the lifecycle listener:

    
     @Override
      protected void onStart() {
          super.onStart();
          playerView.getLifecycleDelegate().start(this);
      }
    
     @Override
      protected void onResume() {
          super.onResume();
          playerView.getLifecycleDelegate().resume();
      }
    
     @Override
      protected void onStop() {
          super.onStop();
          playerView.getLifecycleDelegate().releasePlayer(false);
      }
     
    Please note that the example above does not deal with background playback. Please take a look at PlayerService to see how to integrate the lifecycle events when you are using a service and want to enable background playback.
    Since:
    3.1.0
    • Constructor Detail

      • PlayerView360

        public PlayerView360​(Context context)
    • Method Detail

      • getGvrView

        public com.google.vr.sdk.base.GvrView getGvrView()
        Returns the underlying GvrView.

        You can use the return value of this method as an argument for GvrActivity.setGvrView(GvrView).

        Returns:
        the underlying GvrView
      • getStereoModeEnabled

        public boolean getStereoModeEnabled()
      • setStereoModeEnabled

        public void setStereoModeEnabled​(boolean aEnabled)