PlayerMessage
@UnstableApi
class PlayerMessage
Defines a player message which can be sent with a Sender and received by a Target.
Summary
Nested types |
|---|
interface PlayerMessage.SenderA sender for messages. |
interface PlayerMessage.TargetA target for messages. |
Public constructors |
|---|
PlayerMessage(Creates a new message. |
Public functions |
|
|---|---|
synchronized Boolean |
Blocks until after the message has been delivered or the player is no longer able to deliver the message. |
synchronized Boolean |
blockUntilDelivered(timeoutMs: Long)Blocks until after the message has been delivered or the player is no longer able to deliver the message or the specified timeout elapsed. |
synchronized PlayerMessage! |
Cancels the message delivery. |
synchronized Unit |
markAsProcessed(isDelivered: Boolean)Marks the message as processed. |
PlayerMessage! |
Sends the message. |
PlayerMessage! |
@CanIgnoreReturnValueSets a position in the current media item at which the message will be delivered. |
PlayerMessage! |
@CanIgnoreReturnValueSets a position in a media item at which the message will be delivered. |
Public constructors
PlayerMessage
PlayerMessage(
sender: PlayerMessage.Sender!,
target: PlayerMessage.Target!,
timeline: Timeline!,
defaultMediaItemIndex: Int,
clock: Clock!,
defaultLooper: Looper!
)
Creates a new message.
| Parameters | |
|---|---|
sender: PlayerMessage.Sender! |
The |
target: PlayerMessage.Target! |
The |
timeline: Timeline! |
The timeline used when setting the position with |
defaultMediaItemIndex: Int |
The default media item index in the |
clock: Clock! |
The |
defaultLooper: Looper! |
The default |
Public functions
blockUntilDelivered
synchronized fun blockUntilDelivered(): Boolean
Blocks until after the message has been delivered or the player is no longer able to deliver the message.
Note that this method must not be called if the current thread is the same thread used by the message looper as it would cause a deadlock.
| Returns | |
|---|---|
Boolean |
Whether the message was delivered successfully. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If this method is called before |
java.lang.IllegalStateException |
If this method is called on the same thread used by the message |
java.lang.InterruptedException |
If the current thread is interrupted while waiting for the message to be delivered. |
blockUntilDelivered
synchronized fun blockUntilDelivered(timeoutMs: Long): Boolean
Blocks until after the message has been delivered or the player is no longer able to deliver the message or the specified timeout elapsed.
Note that this method must not be called if the current thread is the same thread used by the message looper as it would cause a deadlock.
| Parameters | |
|---|---|
timeoutMs: Long |
The timeout in milliseconds. |
| Returns | |
|---|---|
Boolean |
Whether the message was delivered successfully. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If this method is called before |
java.lang.IllegalStateException |
If this method is called on the same thread used by the message |
java.util.concurrent.TimeoutException |
If the |
java.lang.InterruptedException |
If the current thread is interrupted while waiting for the message to be delivered. |
cancel
@CanIgnoreReturnValue
synchronized fun cancel(): PlayerMessage!
Cancels the message delivery.
| Returns | |
|---|---|
PlayerMessage! |
This message. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If this method is called before |
markAsProcessed
synchronized fun markAsProcessed(isDelivered: Boolean): Unit
Marks the message as processed. Should only be called by a Sender and may be called multiple times.
| Parameters | |
|---|---|
isDelivered: Boolean |
Whether the message has been delivered to its target. The message is considered as being delivered when this method has been called with |
send
@CanIgnoreReturnValue
fun send(): PlayerMessage!
Sends the message. If the target throws an ExoPlaybackException then it is propagated out of the player as an error using onPlayerError.
| Returns | |
|---|---|
PlayerMessage! |
This message. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If this message has already been sent. |
setPosition
@CanIgnoreReturnValue
fun setPosition(positionMs: Long): PlayerMessage!
Sets a position in the current media item at which the message will be delivered.
| Parameters | |
|---|---|
positionMs: Long |
The position in the current media item at which the message will be sent, in milliseconds, or |
| Returns | |
|---|---|
PlayerMessage! |
This message. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setPosition
@CanIgnoreReturnValue
fun setPosition(mediaItemIndex: Int, positionMs: Long): PlayerMessage!
Sets a position in a media item at which the message will be delivered.
| Parameters | |
|---|---|
mediaItemIndex: Int |
The index of the media item at which the message will be sent. |
positionMs: Long |
The position in the media item with index |
| Returns | |
|---|---|
PlayerMessage! |
This message. |
| Throws | |
|---|---|
androidx.media3.common.IllegalSeekPositionException |
If the timeline returned by |
java.lang.IllegalStateException |
If |