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 ofPlayerListeners 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 thefireError(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(AdInterface.Listener listener)voidaddListener(CustomDashEventListener listener)Register the givenCustomDashEventListenervoidfireError(CastlabsPlayerException error)Iterates the registered listeners and delegates toPlayerListener.onError(CastlabsPlayerException).voidfireFatalErrorOccurred(CastlabsPlayerException error)Iterates the registered listeners and delegates toPlayerListener.onFatalErrorOccurred(CastlabsPlayerException).voidfireLicenseKeysChanged()INTERNAL: Fire an license keys changed event to all registered listeners.voidfireLicenseKeysLoaded()INTERNAL: Fire an license keys loaded event to all registered listeners.voidfireLicenseLoadError(int currentAttempt, int maxAttempts, DownloadException downloadException)voidremoveListener(AdInterface.Listener listener)voidremoveListener(CustomDashEventListener listener)Remove the givenCustomDashEventListenervoidreportConnectivityGained()Call this method to report loss of connectivity.voidreportConnectivityLost()Call this method to report loss of connectivity.voidreset()
-
-
-
Method Detail
-
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 givenCustomDashEventListener- Parameters:
listener- the listener
-
removeListener
public void removeListener(@NonNull CustomDashEventListener listener)Remove the givenCustomDashEventListener- Parameters:
listener- the listener
-
fireFatalErrorOccurred
public void fireFatalErrorOccurred(@NonNull CastlabsPlayerException error)Iterates the registered listeners and delegates toPlayerListener.onFatalErrorOccurred(CastlabsPlayerException).- Parameters:
error- the error
-
fireError
public void fireError(@NonNull CastlabsPlayerException error)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.
-
fireLicenseLoadError
public void fireLicenseLoadError(int currentAttempt, int maxAttempts, @Nullable DownloadException downloadException)
-
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()
-
-