Interface MultiControllerPlaylist.PlaylistListener
- All Known Implementing Classes:
MultiControllerPlaylist.AbstractPlaylistListener
- Enclosing class:
MultiControllerPlaylist
public static interface MultiControllerPlaylist.PlaylistListener
Playlist-related events listener.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
onControllerCreate
(PlayerController playerController) Called when aPlayerController
is created.void
onControllerDestroy
(PlayerController playerController) Player controller is destroyed.void
onControllerError
(PlayerController controller, CastlabsPlayerException error, PlayerConfig config) Called if aPlayerController
fires an error.onControllerLoad
(PlayerConfig config, PlayerController playerController) Called right before starting to load an item into the givenPlayerController
.void
onControllerRelease
(PlayerController playerController) Player controller is released.void
onItemChange
(PlayerConfig newConfig, PlayerController oldController, PlayerController newController) Called every time a new playlist item is about to start.void
onPlaylistEndReached
(boolean willLoop) Called whenever the MultiControllerPlaylist has played the last item in the playlist.
-
Method Details
-
onItemChange
void onItemChange(@NonNull PlayerConfig newConfig, @Nullable PlayerController oldController, @Nullable PlayerController newController) Called every time a new playlist item is about to start. As the internal implementation uses two separatePlayerControllers
, the client code should take care of binding / unbinding the appropriate listeners and UI elements.This method will be also called for the first element in the playlist, with a null oldController.
You can use
MultiControllerPlaylist.migratePlayerListeners(PlayerController, PlayerController)
to remove player listeners from the old PlayerController and add them to the new one.- Parameters:
newConfig
- The config representing the new playlist item, which is about to be played.oldController
- Old PlayerController. Should be used to unbind listeners and UI elements.newController
- New PlayerController, where playback will happen.
-
onControllerCreate
Called when aPlayerController
is created.- Parameters:
playerController
- the PlayerController just created
-
onControllerLoad
@Nullable PlayerConfig onControllerLoad(@NonNull PlayerConfig config, @NonNull PlayerController playerController) Called right before starting to load an item into the givenPlayerController
.This controller could be in background at the moment and getting ready to play the next item.
- Parameters:
config
- thePlayerConfig
that is going to be loaded onto the controller.playerController
- the controller which is going to load the config.- Returns:
PlayerConfig
that the Controller will load. You can use this method to create a modified Config from the param. If null, the original config will be used.
-
onControllerRelease
Player controller is released. This means the controller is no longer loading / playing an item.- Parameters:
playerController
- the controller being released
-
onControllerDestroy
Player controller is destroyed. This means the controller will no longer be used.- Parameters:
playerController
- the controller being destroyed.
-
onControllerError
void onControllerError(@NonNull PlayerController controller, @NonNull CastlabsPlayerException error, @NonNull PlayerConfig config) Called if aPlayerController
fires an error. This controller could be in background and pre-loading an item, or it could be the current controller.- Parameters:
controller
- the controller firing the errorerror
- the errorconfig
- thePlayerConfig
which is loaded onto the error-firing controller.
-
onPlaylistEndReached
void onPlaylistEndReached(boolean willLoop) Called whenever the MultiControllerPlaylist has played the last item in the playlist.This will also be triggered by calling
MultiControllerPlaylist.nextItem()
while already playing the last item.- Parameters:
willLoop
- whether the Playlist willMultiControllerPlaylist.enableLooping(boolean)
loop and start over from the first item or not.
-