Package com.castlabs.android.player.playlist

## Class MultiControllerPlaylist.AbstractPlaylistListener

- java.lang.Object
- - com.castlabs.android.player.playlist.MultiControllerPlaylist.AbstractPlaylistListener

- All Implemented Interfaces:
    `MultiControllerPlaylist.PlaylistListener`
  Enclosing class:
    MultiControllerPlaylist

      public abstract static class MultiControllerPlaylist.AbstractPlaylistListener
      extends Object
      implements MultiControllerPlaylist.PlaylistListener

  Abstract implementation of the `MultiControllerPlaylist.PlaylistListener`.

  All methods of the the `MultiControllerPlaylist.PlaylistListener` are implemented with empty bodies and you can extend this class if you only need to implement a subset of the callbacks. Using this abstract class instead of the interface might also simplify updates of the API.

  Since:
    4.2.2

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `AbstractPlaylistListener()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `onControllerCreate​(PlayerController playerController)` | Called when a `PlayerController` is created.
    `void` | `onControllerDestroy​(PlayerController playerController)` | Player controller is destroyed.
    `void` | `onControllerError​(PlayerController controller, CastlabsPlayerException error, PlayerConfig config)` | Called if a `PlayerController` fires an error.
    `PlayerConfig` | `onControllerLoad​(PlayerConfig config, PlayerController playerController)` | Called right before starting to load an item into the given `PlayerController`.
    `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.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractPlaylistListener

          public AbstractPlaylistListener()

  - ### Method Detail

    - #### onItemChange

          public void onItemChange​(@NonNull
                                   PlayerConfig newConfig,
                                   @Nullable
                                   PlayerController oldController,
                                   @Nullable
                                   PlayerController newController)

      Description copied from interface: `MultiControllerPlaylist.PlaylistListener`
      Called every time a new playlist item is about to start. As the internal implementation uses two separate `PlayerControllers`, 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.

      Specified by:
        `onItemChange` in interface `MultiControllerPlaylist.PlaylistListener`
      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

          public void onControllerCreate​(@NonNull
                                         PlayerController playerController)

      Description copied from interface: `MultiControllerPlaylist.PlaylistListener`
      Called when a `PlayerController` is created.
      Specified by:
        `onControllerCreate` in interface `MultiControllerPlaylist.PlaylistListener`
      Parameters:
        `playerController` - the PlayerController just created

    - #### onControllerLoad

          @Nullable
          public PlayerConfig onControllerLoad​(@NonNull
                                               PlayerConfig config,
                                               @NonNull
                                               PlayerController playerController)

      Description copied from interface: `MultiControllerPlaylist.PlaylistListener`
      Called right before starting to load an item into the given `PlayerController`.

      This controller could be in background at the moment and getting ready to play the next item.

      Specified by:
        `onControllerLoad` in interface `MultiControllerPlaylist.PlaylistListener`
      Parameters:
        `config` - the `PlayerConfig` 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

          public void onControllerRelease​(@NonNull
                                          PlayerController playerController)

      Description copied from interface: `MultiControllerPlaylist.PlaylistListener`
      Player controller is released. This means the controller is no longer loading / playing an item.
      Specified by:
        `onControllerRelease` in interface `MultiControllerPlaylist.PlaylistListener`
      Parameters:
        `playerController` - the controller being released

    - #### onControllerDestroy

          public void onControllerDestroy​(@NonNull
                                          PlayerController playerController)

      Description copied from interface: `MultiControllerPlaylist.PlaylistListener`
      Player controller is destroyed. This means the controller will no longer be used.
      Specified by:
        `onControllerDestroy` in interface `MultiControllerPlaylist.PlaylistListener`
      Parameters:
        `playerController` - the controller being destroyed.

    - #### onControllerError

          public void onControllerError​(@NonNull
                                        PlayerController controller,
                                        @NonNull
                                        CastlabsPlayerException error,
                                        @NonNull
                                        PlayerConfig config)

      Description copied from interface: `MultiControllerPlaylist.PlaylistListener`
      Called if a `PlayerController` fires an error. This controller could be in background and pre-loading an item, or it could be the current controller.
      Specified by:
        `onControllerError` in interface `MultiControllerPlaylist.PlaylistListener`
      Parameters:
        `controller` - the controller firing the error
        `error` - the error
        `config` - the `PlayerConfig` which is loaded onto the error-firing controller.

    - #### onPlaylistEndReached

          public void onPlaylistEndReached​(boolean willLoop)

      Description copied from interface: `MultiControllerPlaylist.PlaylistListener`
      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.

      Specified by:
        `onPlaylistEndReached` in interface `MultiControllerPlaylist.PlaylistListener`
      Parameters:
        `willLoop` - whether the Playlist will `MultiControllerPlaylist.enableLooping(boolean)`loop and start over from the first item or not.