Package com.castlabs.android.player
Interface IPlayerView
- All Known Implementing Classes:
PlayerView
public interface IPlayerView
This interface describes the visual component of the video player. It is used in conjunction
with a
PlayerController
. Once the controller is available, you need to set the
view using PlayerController.setPlayerView(IPlayerView)
.- Since:
- 3.0.3
-
Method Summary
Modifier and TypeMethodDescriptionThis method must return an instance of thePlayerViewLifecycleDelegate
.Returns the current instance of thePlayerController
that is used by this view.Retrieve the root view of the currentIPlayerView
implementation.int
Retrieve the video container view of the currentIPlayerView
implementation.void
This method is called by thePlayerController
once the player and the renderer are available.void
This method is called by thePlayerController
once the player is released.void
setPlayerController
(PlayerController playerController) Set the player controller used by this view.void
setScalingMode
(int scalingMode) void
setVisible
(boolean visible) Allow to show ore hide this player view.Returns the current instance of thePlayerController
that is used by this view.
-
Method Details
-
getRootView
Retrieve the root view of the currentIPlayerView
implementation. The video container view is added internally to the root view with the index zero. All other child views when added to the root view are on top of video container view and do not respect the video container aspect ratio.- Returns:
- The root view of the current
IPlayerView
implementation
-
getVideoView
Retrieve the video container view of the currentIPlayerView
implementation. All the child view when added to the video container view do respect the video container aspect ratio.- Returns:
- The video container view of the current
IPlayerView
implementation
-
setVisible
void setVisible(boolean visible) Allow to show ore hide this player view. This is used by the player controller in case the the player view needs to be made invisible. For example, if a secondary display is connected and content playback should be prevented, playback will stop and this method will be used hide the player view.- Parameters:
visible
- True if the view should be visible
-
prepareSurface
void prepareSurface()This method is called by thePlayerController
once the player and the renderer are available. Implementations should create the video surface here and push it to the controller usingPlayerController.setSurface(Surface)
. Please note that you usually also need to setup a listener on the surface and delegate create and destroy events to the underlying player controller also usingPlayerController.setSurface(Surface)
. -
removeSurface
void removeSurface()This method is called by thePlayerController
once the player is released. Implementations should remove the video surface if it exists. -
getPlayerController
Returns the current instance of thePlayerController
that is used by this view. Note that you can create the controller lazily here as well, but the implementation must be able to take a controller instance throughsetPlayerController(PlayerController)
. In addition, if you are creating the controller here, make sure that the bi-directional link between the view and the controller is established by callingPlayerController.setPlayerView(IPlayerView)
.- Returns:
- The player controller instance that is used to render video to this view
-
tryPlayerController
Returns the current instance of thePlayerController
that is used by this view. Note that you do not create the controller lazily here.- Returns:
- The player controller instance that is used to render video to this view
-
setPlayerController
Set the player controller used by this view. The implementation must ensure that the bi-directional link between the controller and this view is established (or reset if a controller already exists). You must callPlayerController.setPlayerView(IPlayerView)
to establish this link. In addition, this method might be called with anull
argument, which indicates that the view is disposed and should break the relation with the current controller. In that case the implementation must ensure to callPlayerController.setPlayerView(IPlayerView)
with anull
argument and remove any listeners that were attached to the controller. This is used for example when reattaching to an existing controller.. When you are using aPlayerService
, the service will automatically reattach the controller and call this method. When you are using the view without a service, the view should create a controller for you automatically whengetPlayerController()
is called the first time.- Parameters:
playerController
- The player controller
-
getLifecycleDelegate
This method must return an instance of thePlayerViewLifecycleDelegate
. That instance can be used to integrate the view and its controller with an Activity lifecycle. Please note that the returned instance might also be used implicitly when thePlayerService
is used and the player is send to background.- Returns:
- The lifecycle delegate that is used to integrate this view into activity life cycles
-
getScalingMode
int getScalingMode() -
setScalingMode
void setScalingMode(int scalingMode)
-