PlayerExtensionsKt
public final class PlayerExtensionsKt
Summary
Public methods |
|
|---|---|
static final @NonNull Void |
@UnstableApiContinuously listens to the |
static final @NonNull Void |
@UnstableApiContinuously listens to the |
Public methods
listen
@UnstableApi
public static final @NonNull Void listen(
@NonNull Player receiver,
@NonNull Function2<@NonNull Player, @NonNull Player.Events, Unit> onEvents
)
Continuously listens to the Player.Listener.onEvents callback, passing the received Player.Events to the provided onEvents function.
This function can be called from any thread. The onEvents function will be invoked on the thread associated with Player.getApplicationLooper.
If, during the execution of onEvents, an exception is thrown, the coroutine corresponding to listening to the Player will be terminated. Any used resources will be cleaned up (e.g. removing of the listeners) and exception will be re-thrown right after the last suspension point.
listenTo
@UnstableApi
public static final @NonNull Void listenTo(
@NonNull Player receiver,
@Player.Event int firstEvent,
@Player.Event int... otherEvents,
@NonNull Function2<@NonNull Player, @NonNull Player.Events, Unit> onEvents
)
Continuously listens to the Player.Listener.onEvents callback, passing the received Player.Events to the provided onEvents function. A non-zero number of events has to be specified (hence firstEvent and otherEvents). The order is not important.
This function can be called from any thread. The onEvents function will be invoked on the thread associated with Player.getApplicationLooper.
If, during the execution of onEvents, an exception is thrown, the coroutine corresponding to listening to the Player will be terminated. Any used resources will be cleaned up (e.g. removing of the listeners) and exception will be re-thrown right after the last suspension point.
| Parameters | |
|---|---|
@Player.Event int firstEvent |
One of the |
@Player.Event int... otherEvents |
The set of other |
@NonNull Function2<@NonNull Player, @NonNull Player.Events, Unit> onEvents |
The function to handle player events. |