Package com.castlabs.android.player

# Class PlayerListeners

java.lang.Object
com.castlabs.android.player.PlayerListeners

public class PlayerListeners extends Object
This class helps to manage a set of `PlayerListener`s and delegates to the listener methods. It can manages the list of listeners and ensure that concurrent modification are prevented and listeners can be added and removed in a thread safe manner.

If you are using the `fireError(CastlabsPlayerException)` methods to delegate errors to the listeners, please note that the delegation will be done one the same thread.

Since:
  3.0.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addListener(AdInterface.Listener listener)`
  `void`
  `addListener(CustomDashEventListener listener)`
  Register the given `CustomDashEventListener`
  `void`
  `addListener(EventStreamListener listener)`
  Register the given `EventStreamListener`
  `void`
  `addListener(EventStreamListListener listener)`
  Register the given `EventStreamListListener`
  `void`
  `fireError(CastlabsPlayerException error)`
  Iterates the registered listeners and delegates to `PlayerListener.onError(CastlabsPlayerException)`.
  `void`
  `fireFatalErrorOccurred(CastlabsPlayerException error)`
  Iterates the registered listeners and delegates to `PlayerListener.onFatalErrorOccurred(CastlabsPlayerException)`.
  `void`
  `fireLicenseKeysChanged()`
  INTERNAL: Fire an license keys changed event to all registered listeners.
  `void`
  `fireLicenseKeysLoaded()`
  INTERNAL: Fire an license keys loaded event to all registered listeners.
  `void`
  `fireLicenseLoadError(int currentAttempt, int maxAttempts, DownloadException downloadException)`
  `void`
  `fireOnAdClicked(String clickthroughUrl)`
  `void`
  `fireOnAdPaused()`
  `void`
  `fireOnAdResumed(Ad ad)`
  `void`
  `removeListener(AdInterface.Listener listener)`
  `void`
  `removeListener(CustomDashEventListener listener)`
  Remove the given `CustomDashEventListener`
  `void`
  `removeListener(EventStreamListener listener)`
  Remove the given `EventStreamListener`
  `void`
  `removeListener(EventStreamListListener listener)`
  Remove the given `EventStreamListListener`
  `void`
  `reportConnectivityGained()`
  Call this method to report loss of connectivity.
  `void`
  `reportConnectivityLost()`
  Call this method to report loss of connectivity.
  `void`
  `reset()`

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

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

- ## Method Details

  - ### removeListener

    public void removeListener(@NonNull AdInterface.Listener listener)

  - ### addListener

    public void addListener(@NonNull AdInterface.Listener listener)

  - ### addListener

    public void addListener(@NonNull CustomDashEventListener listener)
    Register the given `CustomDashEventListener`
    Parameters:
      `listener` - the listener

  - ### addListener

    public void addListener(@NonNull EventStreamListener listener)
    Register the given `EventStreamListener`
    Parameters:
      `listener` - the listener

  - ### removeListener

    public void removeListener(@NonNull CustomDashEventListener listener)
    Remove the given `CustomDashEventListener`
    Parameters:
      `listener` - the listener

  - ### removeListener

    public void removeListener(@NonNull EventStreamListener listener)
    Remove the given `EventStreamListener`
    Parameters:
      `listener` - the listener

  - ### addListener

    public void addListener(@NonNull EventStreamListListener listener)
    Register the given `EventStreamListListener`
    Parameters:
      `listener` - the listener

  - ### removeListener

    public void removeListener(@NonNull EventStreamListListener listener)
    Remove the given `EventStreamListListener`
    Parameters:
      `listener` - the listener

  - ### fireFatalErrorOccurred

    public void fireFatalErrorOccurred(@NonNull CastlabsPlayerException error)
    Iterates the registered listeners and delegates to `PlayerListener.onFatalErrorOccurred(CastlabsPlayerException)`.
    Parameters:
      `error` - the error

  - ### fireError

    public void fireError(@NonNull CastlabsPlayerException error)
    Iterates the registered listeners and delegates to `PlayerListener.onError(CastlabsPlayerException)`.
    Parameters:
      `error` - the error

  - ### fireLicenseKeysLoaded

    public void fireLicenseKeysLoaded()
    INTERNAL: Fire an license keys loaded event to all registered listeners.

  - ### fireLicenseKeysChanged

    public void fireLicenseKeysChanged()
    INTERNAL: Fire an license keys changed event to all registered listeners.

  - ### fireLicenseLoadError

    public void fireLicenseLoadError(int currentAttempt, int maxAttempts, @Nullable DownloadException downloadException)

  - ### fireOnAdPaused

    public void fireOnAdPaused()

  - ### fireOnAdResumed

    public void fireOnAdResumed(@NonNull Ad ad)

  - ### fireOnAdClicked

    public void fireOnAdClicked(@Nullable String clickthroughUrl)

  - ### reportConnectivityLost

    public void reportConnectivityLost()
    Call this method to report loss of connectivity. This will delegate a new error to any registered listeners and cache the connectivity state.

  - ### reportConnectivityGained

    public void reportConnectivityGained()
    Call this method to report loss of connectivity. This will delegate a new error to any registered listeners and cache the connectivity state.

  - ### reset

    public void reset()