docs/doc/reference/com/google/android/exoplayer2/PlayerMessage.html
Package com.google.android.exoplayer2
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public final classPlayerMessageextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")
Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
Defines a player message which can be sent with a PlayerMessage.Sender and received by a PlayerMessage.Target.
Nested Classes | Modifier and Type | Class | Description |
| --- | --- | --- |
| static interface | PlayerMessage.Sender |
Deprecated.
A sender for messages.
|
| static interface | PlayerMessage.Target |
Deprecated.
A target for messages. |
Constructors | Constructor | Description |
| --- | --- |
| PlayerMessage(PlayerMessage.Sender sender, PlayerMessage.Target target, Timeline timeline, int defaultMediaItemIndex, Clock clock, Looper defaultLooper) |
Deprecated.
Creates a new message. |
All Methods Instance Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| boolean | blockUntilDelivered() |
Deprecated.
Blocks until after the message has been delivered or the player is no longer able to deliver the message.
|
| boolean | blockUntilDelivered(long timeoutMs) |
Deprecated.
Blocks until after the message has been delivered or the player is no longer able to deliver the message or the specified timeout elapsed.
|
| PlayerMessage | cancel() |
Deprecated.
Cancels the message delivery.
|
| boolean | getDeleteAfterDelivery() |
Deprecated.
Returns whether the message will be deleted after delivery.
|
| Looper | getLooper() |
Deprecated.
Returns the Looper the message is delivered on.
|
| int | getMediaItemIndex() |
Deprecated.
Returns media item index at which the message will be delivered.
|
| Object | getPayload() |
Deprecated.
Returns the message payload forwarded to PlayerMessage.Target.handleMessage(int, Object).
|
| long | getPositionMs() |
Deprecated.
Returns position in the media item at getMediaItemIndex() at which the message will be delivered, in milliseconds.
|
| PlayerMessage.Target | getTarget() |
Deprecated.
Returns the target the message is sent to.
|
| Timeline | getTimeline() |
Deprecated.
Returns the timeline used for setting the position with setPosition(long).
|
| int | getType() |
Deprecated.
Returns the message type forwarded to PlayerMessage.Target.handleMessage(int, Object).
|
| boolean | isCanceled() |
Deprecated.
Returns whether the message delivery has been canceled.
|
| void | markAsProcessed(boolean isDelivered) |
Deprecated.
Marks the message as processed.
|
| PlayerMessage | send() |
Deprecated.
Sends the message.
|
| PlayerMessage | setDeleteAfterDelivery(boolean deleteAfterDelivery) |
Deprecated.
Sets whether the message will be deleted after delivery.
|
| PlayerMessage | setHandler(Handler handler) |
Deprecated.
Use setLooper(Looper) instead.
|
| PlayerMessage | setLooper(Looper looper) |
Deprecated.
Sets the Looper the message is delivered on.
|
| PlayerMessage | setPayload(Object payload) |
Deprecated.
Sets the message payload forwarded to PlayerMessage.Target.handleMessage(int, Object).
|
| PlayerMessage | setPosition(int mediaItemIndex, long positionMs) |
Deprecated.
Sets a position in a media item at which the message will be delivered.
|
| PlayerMessage | setPosition(long positionMs) |
Deprecated.
Sets a position in the current media item at which the message will be delivered.
|
| PlayerMessage | setType(int messageType) |
Deprecated.
Sets the message type forwarded to PlayerMessage.Target.handleMessage(int, Object).
|
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public PlayerMessage([PlayerMessage.Sender](PlayerMessage.Sender.html "interface in com.google.android.exoplayer2")sender,[PlayerMessage.Target](PlayerMessage.Target.html "interface in com.google.android.exoplayer2")target,[Timeline](Timeline.html "class in com.google.android.exoplayer2")timeline,
int defaultMediaItemIndex,[Clock](util/Clock.html "interface in com.google.android.exoplayer2.util")clock,[Looper](https://developer.android.com/reference/android/os/Looper.html "class or interface in android.os")defaultLooper)
Deprecated.
Creates a new message.
Parameters:sender - The PlayerMessage.Sender used to send the message.target - The PlayerMessage.Target the message is sent to.timeline - The timeline used when setting the position with setPosition(long). If set to Timeline.EMPTY, any position can be specified.defaultMediaItemIndex - The default media item index in the timeline when no other media item index is specified.clock - The Clock.defaultLooper - The default Looper to send the message on when no other looper is specified.
-
public[Timeline](Timeline.html "class in com.google.android.exoplayer2")getTimeline()
Deprecated.
Returns the timeline used for setting the position with setPosition(long).
-
public[PlayerMessage.Target](PlayerMessage.Target.html "interface in com.google.android.exoplayer2")getTarget()
Deprecated.
Returns the target the message is sent to.
-
@CanIgnoreReturnValue
public[PlayerMessage](PlayerMessage.html "class in com.google.android.exoplayer2")setType(int messageType)
Deprecated.
Sets the message type forwarded to PlayerMessage.Target.handleMessage(int, Object).
Parameters:messageType - The message type.Returns:This message.Throws:IllegalStateException - If send() has already been called.
-
public int getType()
Deprecated.
Returns the message type forwarded to PlayerMessage.Target.handleMessage(int, Object).
-
@CanIgnoreReturnValue
public[PlayerMessage](PlayerMessage.html "class in com.google.android.exoplayer2")setPayload(@Nullable[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")payload)
Deprecated.
Sets the message payload forwarded to PlayerMessage.Target.handleMessage(int, Object).
Parameters:payload - The message payload.Returns:This message.Throws:IllegalStateException - If send() has already been called.
-
@Nullable
public[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")getPayload()
Deprecated.
Returns the message payload forwarded to PlayerMessage.Target.handleMessage(int, Object).
-
@CanIgnoreReturnValue[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public[PlayerMessage](PlayerMessage.html "class in com.google.android.exoplayer2")setHandler([Handler](https://developer.android.com/reference/android/os/Handler.html "class or interface in android.os")handler)
Deprecated.
Use setLooper(Looper) instead.
-
@CanIgnoreReturnValue
public[PlayerMessage](PlayerMessage.html "class in com.google.android.exoplayer2")setLooper([Looper](https://developer.android.com/reference/android/os/Looper.html "class or interface in android.os")looper)
Deprecated.
Sets the Looper the message is delivered on.
Parameters:looper - A Looper.Returns:This message.Throws:IllegalStateException - If send() has already been called.
-
public[Looper](https://developer.android.com/reference/android/os/Looper.html "class or interface in android.os")getLooper()
Deprecated.
Returns the Looper the message is delivered on.
-
public long getPositionMs()
Deprecated.
Returns position in the media item at getMediaItemIndex() at which the message will be delivered, in milliseconds. If C.TIME_UNSET, the message will be delivered immediately. If C.TIME_END_OF_SOURCE, the message will be delivered at the end of the media item at getMediaItemIndex().
-
@CanIgnoreReturnValue
public[PlayerMessage](PlayerMessage.html "class in com.google.android.exoplayer2")setPosition(long positionMs)
Deprecated.
Sets a position in the current media item at which the message will be delivered.
Parameters:positionMs - The position in the current media item at which the message will be sent, in milliseconds, or C.TIME_END_OF_SOURCE to deliver the message at the end of the current media item.Returns:This message.Throws:IllegalStateException - If send() has already been called.
-
@CanIgnoreReturnValue
public[PlayerMessage](PlayerMessage.html "class in com.google.android.exoplayer2")setPosition(int mediaItemIndex,
long positionMs)
Deprecated.
Sets a position in a media item at which the message will be delivered.
Parameters:mediaItemIndex - The index of the media item at which the message will be sent.positionMs - The position in the media item with index mediaItemIndex at which the message will be sent, in milliseconds, or C.TIME_END_OF_SOURCE to deliver the message at the end of the media item with index mediaItemIndex.Returns:This message.Throws:IllegalSeekPositionException - If the timeline returned by getTimeline() is not empty and the provided media item index is not within the bounds of the timeline.IllegalStateException - If send() has already been called.
-
public int getMediaItemIndex()
Deprecated.
Returns media item index at which the message will be delivered.
-
@CanIgnoreReturnValue
public[PlayerMessage](PlayerMessage.html "class in com.google.android.exoplayer2")setDeleteAfterDelivery(boolean deleteAfterDelivery)
Deprecated.
Sets whether the message will be deleted after delivery. If false, the message will be resent if playback reaches the specified position again. Only allowed to be false if a position is set with setPosition(long).
Parameters:deleteAfterDelivery - Whether the message is deleted after delivery.Returns:This message.Throws:IllegalStateException - If send() has already been called.
-
public boolean getDeleteAfterDelivery()
Deprecated.
Returns whether the message will be deleted after delivery.
-
@CanIgnoreReturnValue
public[PlayerMessage](PlayerMessage.html "class in com.google.android.exoplayer2")send()
Deprecated.
Sends the message. If the target throws an ExoPlaybackException then it is propagated out of the player as an error using Player.Listener.onPlayerError(PlaybackException).
Returns:This message.Throws:IllegalStateException - If this message has already been sent.
-
@CanIgnoreReturnValue
public[PlayerMessage](PlayerMessage.html "class in com.google.android.exoplayer2")cancel()
Deprecated.
Cancels the message delivery.
Returns:This message.Throws:IllegalStateException - If this method is called before send().
-
public boolean isCanceled()
Deprecated.
Returns whether the message delivery has been canceled.
-
public void markAsProcessed(boolean isDelivered)
Deprecated.
Marks the message as processed. Should only be called by a PlayerMessage.Sender and may be called multiple times.
Parameters:isDelivered - Whether the message has been delivered to its target. The message is considered as being delivered when this method has been called with isDelivered set to true at least once.
-
public boolean blockUntilDelivered()
throws[InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html "class or interface in java.lang")
Deprecated.
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:Whether the message was delivered successfully.Throws:IllegalStateException - If this method is called before send().IllegalStateException - If this method is called on the same thread used by the message looper.InterruptedException - If the current thread is interrupted while waiting for the message to be delivered.
-
public boolean blockUntilDelivered(long timeoutMs)
throws[InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html "class or interface in java.lang"),[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Deprecated.
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 - The timeout in milliseconds.Returns:Whether the message was delivered successfully.Throws:IllegalStateException - If this method is called before send().IllegalStateException - If this method is called on the same thread used by the message looper.TimeoutException - If the timeoutMs elapsed and this message has not been delivered and the player is still able to deliver the message.InterruptedException - If the current thread is interrupted while waiting for the message to be delivered.