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 Details

    • PlayerView360

      public PlayerView360(Context context)
      Instantiates a new PlayerView360.
      Parameters:
      context - the context
    • PlayerView360

      public PlayerView360(Context context, AttributeSet attrs)
      Instantiates a new PlayerView360.
      Parameters:
      context - the context
      attrs - the attrs
    • PlayerView360

      public PlayerView360(Context context, AttributeSet attrs, int defStyle)
      Instantiates a new PlayerView360.
      Parameters:
      context - the context
      attrs - the attrs
      defStyle - the def style
  • Method Details

    • onTouchEvent

      public boolean onTouchEvent(MotionEvent e)
      Overrides:
      onTouchEvent in class View
    • 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
    • removeSurface

      public void removeSurface()
      Specified by:
      removeSurface in interface IPlayerView
      Overrides:
      removeSurface in class PlayerView
    • getStereoModeEnabled

      public boolean getStereoModeEnabled()
      Returns whether stereo mode is enabled or disabled.
      Returns:
      true if stereo mode is enabled, false otherwise.
    • setStereoModeEnabled

      public void setStereoModeEnabled(boolean aEnabled)
      Enable/Disable stereo mode.
      Parameters:
      aEnabled - true to enable stereo mode, false to disable it.
    • setOnCloseButtonClickListener

      public void setOnCloseButtonClickListener(PlayerView360.OnCloseButtonListener aListener)
      Sets a listener for the close button in stereo mode. If aListener = null, the listener will be removed.
      Parameters:
      aListener - The listener to set, or null to remove the current listener.