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.ComponentViewListenerwith thePlayerControllerPlugin.Componentmachinery.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
listenerin 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
listeneras 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 voidonComponentViewsChanged(PlayerController playerController)Called whenever the list of ComponentViews in thePlayerControllerhas changed.voidonDestroy(PlayerController playerController)Called when the controller is destroyed.voidonOpenBundle(PlayerController playerController, Bundle bundle)Called when the player controller is opened with a bundle.voidonOpenState(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.voidsetComponentViewListener(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.ComponentCalled when the controller is destroyed. Implementation must use this to unregister any listeners that were attached to the controller before.- Specified by:
onDestroyin interfacePlayerControllerPlugin.Component- Parameters:
playerController- The player controller
-
onOpenBundle
public void onOpenBundle(@NonNull PlayerController playerController, @NonNull Bundle bundle)Description copied from interface:PlayerControllerPlugin.ComponentCalled when the player controller is opened with a bundle. Implementations can use this to extract or modify bundle data.- Specified by:
onOpenBundlein interfacePlayerControllerPlugin.Component- Parameters:
playerController- The player controllerbundle- The bundle
-
onOpenState
public void onOpenState(PlayerController playerController, PlayerConfig playerConfig)
Description copied from interface:PlayerControllerPlugin.ComponentCalled when the player controller is opened with a config. Implementations can use this to extract or modify config data.- Specified by:
onOpenStatein interfacePlayerControllerPlugin.Component- Parameters:
playerController- The player controllerplayerConfig- The playback state
-
onComponentViewsChanged
public void onComponentViewsChanged(@NonNull PlayerController playerController)Description copied from interface:PlayerControllerPlugin.ComponentViewListenerCalled whenever the list of ComponentViews in thePlayerControllerhas 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:
onComponentViewsChangedin interfacePlayerControllerPlugin.ComponentViewListener- Parameters:
playerController- the PlayerController firing this event.
-
scanComponentViews
public Collection<Pair<Integer,View>> scanComponentViews(@NonNull ViewGroup container)
Description copied from interface:PlayerControllerPlugin.ComponentViewListenerImplementors 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:
scanComponentViewsin 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
-
-