Package com.castlabs.android.player
Class PlayerListeners
java.lang.Object
com.castlabs.android.player.PlayerListeners
This class helps to manage a set of
PlayerListeners 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 TypeMethodDescriptionvoidaddListener(AdInterface.Listener listener) Adds an ad listener.voidaddListener(CustomDashEventListener listener) Register the givenCustomDashEventListenervoidaddListener(EventStreamListener listener) Register the givenEventStreamListenervoidaddListener(EventStreamListListener listener) Register the givenEventStreamListListenervoidfireError(CastlabsPlayerException error) Iterates the registered listeners and delegates toPlayerListener.onError(CastlabsPlayerException).voidIterates the registered listeners and delegates toPlayerListener.onFatalErrorOccurred(CastlabsPlayerException).voidINTERNAL: Fire an license keys changed event to all registered listeners.voidINTERNAL: Fire an license keys loaded event to all registered listeners.voidremoveListener(AdInterface.Listener listener) Removes an ad listener.voidremoveListener(CustomDashEventListener listener) Remove the givenCustomDashEventListenervoidremoveListener(EventStreamListener listener) Remove the givenEventStreamListenervoidremoveListener(EventStreamListListener listener) Remove the givenEventStreamListListenervoidCall this method to report loss of connectivity.voidCall this method to report loss of connectivity.voidreset()Resets any internal state related to listeners
-
Method Details
-
removeListener
Removes an ad listener.- Parameters:
listener- The listener to remove. Must not be null.- Throws:
NullPointerException- if the listener is null.
-
addListener
Adds an ad listener.- Parameters:
listener- The listener to add. Must not be null.- Throws:
NullPointerException- if the listener is null.
-
addListener
Register the givenCustomDashEventListener- Parameters:
listener- the listener
-
addListener
Register the givenEventStreamListener- Parameters:
listener- the listener
-
removeListener
Remove the givenCustomDashEventListener- Parameters:
listener- the listener
-
removeListener
Remove the givenEventStreamListener- Parameters:
listener- the listener
-
addListener
Register the givenEventStreamListListener- Parameters:
listener- the listener
-
removeListener
Remove the givenEventStreamListListener- Parameters:
listener- the listener
-
fireFatalErrorOccurred
Iterates the registered listeners and delegates toPlayerListener.onFatalErrorOccurred(CastlabsPlayerException).- Parameters:
error- the error
-
fireError
Iterates the registered listeners and delegates toPlayerListener.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. -
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()Resets any internal state related to listeners
-