Class VisualComponentProxy
- java.lang.Object
-
- com.castlabs.android.player.VisualComponentProxy
-
- All Implemented Interfaces:
PlayerControllerPlugin.Component
,PlayerControllerPlugin.ComponentViewListener
,PlayerControllerPlugin.VisualComponent
- Direct Known Subclasses:
ExoSubtitlesRendererPlugin.ExoSubtitleComponent
public abstract class VisualComponentProxy extends Object implements PlayerControllerPlugin.VisualComponent
VisualComponent whose task is to communicate aPlayerControllerPlugin.ComponentViewListener
with thePlayerControllerPlugin.Component
machinery.Here we forward the events to a PlayerControllerPlugin.ComponentViewListener. Thus giving it a chance to update its inner
View
.We also take care of async calls. For instance, the SubtitlesTrackRenderer will set the
listener
in its createRenderer() call. This is too late, for instance in the case where the client code usesPlayerController.scanComponentViews(ViewGroup)
. In this case, we would be calledscanComponentViews(ViewGroup)
before having acomponentsViewListener
.That's why we save the ViewGroup and forward the pending call to the
listener
as soon as it is set.Users of this Class should implement the
PlayerControllerPlugin.Component.id()
method returning the concrete Class's class. This is why you should *not* create anonymous concrete Classes.- Since:
- 4.2.2
-
-
Constructor Summary
Constructors Constructor Description VisualComponentProxy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onComponentViewsChanged(PlayerController playerController)
Called whenever the list of ComponentViews in thePlayerController
has changed.void
onDestroy(PlayerController playerController)
Called when the controller is destroyed.void
onOpenBundle(PlayerController playerController, Bundle bundle)
Called when the player controller is opened with a bundle.void
onOpenState(PlayerController playerController, PlayerConfig playerConfig)
Called when the player controller is opened with a config.Collection<Pair<Integer,View>>
scanComponentViews(ViewGroup container)
Implementors should scan for the "desired" Views.void
setComponentViewListener(PlayerControllerPlugin.ComponentViewListener componentsViewListener)
Sets the Listener.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.castlabs.android.player.PlayerControllerPlugin.Component
id
-
-
-
-
Method Detail
-
onDestroy
public void onDestroy(@NonNull PlayerController playerController)
Description copied from interface:PlayerControllerPlugin.Component
Called when the controller is destroyed. Implementation must use this to unregister any listeners that were attached to the controller before.- Specified by:
onDestroy
in interfacePlayerControllerPlugin.Component
- Parameters:
playerController
- The player controller
-
onOpenBundle
public void onOpenBundle(@NonNull PlayerController playerController, @NonNull Bundle bundle)
Description copied from interface:PlayerControllerPlugin.Component
Called when the player controller is opened with a bundle. Implementations can use this to extract or modify bundle data.- Specified by:
onOpenBundle
in interfacePlayerControllerPlugin.Component
- Parameters:
playerController
- The player controllerbundle
- The bundle
-
onOpenState
public void onOpenState(PlayerController playerController, PlayerConfig playerConfig)
Description copied from interface:PlayerControllerPlugin.Component
Called when the player controller is opened with a config. Implementations can use this to extract or modify config data.- Specified by:
onOpenState
in interfacePlayerControllerPlugin.Component
- Parameters:
playerController
- The player controllerplayerConfig
- The playback state
-
onComponentViewsChanged
public void onComponentViewsChanged(@NonNull PlayerController playerController)
Description copied from interface:PlayerControllerPlugin.ComponentViewListener
Called whenever the list of ComponentViews in thePlayerController
has changed. This is whenever a View is added, or removed. Implementors should use this callback to detach from an old View (if any) and attach to the new one (if any). It is possible that there's actually no change affecting one particular ComponentViewListener. In this case the callback should just be ignored.- Specified by:
onComponentViewsChanged
in interfacePlayerControllerPlugin.ComponentViewListener
- Parameters:
playerController
- the PlayerController firing this event.
-
scanComponentViews
public Collection<Pair<Integer,View>> scanComponentViews(@NonNull ViewGroup container)
Description copied from interface:PlayerControllerPlugin.ComponentViewListener
Implementors should scan for the "desired" Views. The Views could be at any hierarchy level, so the use ofView.findViewById(int)
is encouraged. You *should not* hold a reference to the found Views.- Specified by:
scanComponentViews
in interfacePlayerControllerPlugin.ComponentViewListener
- Parameters:
container
- the ViewGroup where there specific Views should be looked for.- Returns:
- a Collection of the found Views in the container
-
setComponentViewListener
public void setComponentViewListener(PlayerControllerPlugin.ComponentViewListener componentsViewListener)
Sets the Listener.Will be immediately called if there's a pending
scanComponentViews(ViewGroup)
call.- Parameters:
componentsViewListener
- the listener to set
-
-