Package com.google.android.exoplayer2
Class PlayerMessage
- java.lang.Object
-
- com.google.android.exoplayer2.PlayerMessage
-
@Deprecated public final class PlayerMessage extends Object
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 aPlayerMessage.Senderand received by aPlayerMessage.Target.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfacePlayerMessage.SenderDeprecated.A sender for messages.static interfacePlayerMessage.TargetDeprecated.A target for messages.
-
Constructor Summary
Constructors Constructor Description PlayerMessage(PlayerMessage.Sender sender, PlayerMessage.Target target, Timeline timeline, int defaultMediaItemIndex, Clock clock, Looper defaultLooper)Deprecated.Creates a new message.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanblockUntilDelivered()Deprecated.Blocks until after the message has been delivered or the player is no longer able to deliver the message.booleanblockUntilDelivered(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.PlayerMessagecancel()Deprecated.Cancels the message delivery.booleangetDeleteAfterDelivery()Deprecated.Returns whether the message will be deleted after delivery.LoopergetLooper()Deprecated.Returns theLooperthe message is delivered on.intgetMediaItemIndex()Deprecated.Returns media item index at which the message will be delivered.ObjectgetPayload()Deprecated.Returns the message payload forwarded toPlayerMessage.Target.handleMessage(int, Object).longgetPositionMs()Deprecated.Returns position in the media item atgetMediaItemIndex()at which the message will be delivered, in milliseconds.PlayerMessage.TargetgetTarget()Deprecated.Returns the target the message is sent to.TimelinegetTimeline()Deprecated.Returns the timeline used for setting the position withsetPosition(long).intgetType()Deprecated.Returns the message type forwarded toPlayerMessage.Target.handleMessage(int, Object).booleanisCanceled()Deprecated.Returns whether the message delivery has been canceled.voidmarkAsProcessed(boolean isDelivered)Deprecated.Marks the message as processed.PlayerMessagesend()Deprecated.Sends the message.PlayerMessagesetDeleteAfterDelivery(boolean deleteAfterDelivery)Deprecated.Sets whether the message will be deleted after delivery.PlayerMessagesetHandler(Handler handler)Deprecated.UsesetLooper(Looper)instead.PlayerMessagesetLooper(Looper looper)Deprecated.Sets theLooperthe message is delivered on.PlayerMessagesetPayload(Object payload)Deprecated.Sets the message payload forwarded toPlayerMessage.Target.handleMessage(int, Object).PlayerMessagesetPosition(int mediaItemIndex, long positionMs)Deprecated.Sets a position in a media item at which the message will be delivered.PlayerMessagesetPosition(long positionMs)Deprecated.Sets a position in the current media item at which the message will be delivered.PlayerMessagesetType(int messageType)Deprecated.Sets the message type forwarded toPlayerMessage.Target.handleMessage(int, Object).
-
-
-
Constructor Detail
-
PlayerMessage
public PlayerMessage(PlayerMessage.Sender sender, PlayerMessage.Target target, Timeline timeline, int defaultMediaItemIndex, Clock clock, Looper defaultLooper)
Deprecated.Creates a new message.- Parameters:
sender- ThePlayerMessage.Senderused to send the message.target- ThePlayerMessage.Targetthe message is sent to.timeline- The timeline used when setting the position withsetPosition(long). If set toTimeline.EMPTY, any position can be specified.defaultMediaItemIndex- The default media item index in thetimelinewhen no other media item index is specified.clock- TheClock.defaultLooper- The defaultLooperto send the message on when no other looper is specified.
-
-
Method Detail
-
getTimeline
public Timeline getTimeline()
Deprecated.Returns the timeline used for setting the position withsetPosition(long).
-
getTarget
public PlayerMessage.Target getTarget()
Deprecated.Returns the target the message is sent to.
-
setType
@CanIgnoreReturnValue public PlayerMessage setType(int messageType)
Deprecated.Sets the message type forwarded toPlayerMessage.Target.handleMessage(int, Object).- Parameters:
messageType- The message type.- Returns:
- This message.
- Throws:
IllegalStateException- Ifsend()has already been called.
-
getType
public int getType()
Deprecated.Returns the message type forwarded toPlayerMessage.Target.handleMessage(int, Object).
-
setPayload
@CanIgnoreReturnValue public PlayerMessage setPayload(@Nullable Object payload)
Deprecated.Sets the message payload forwarded toPlayerMessage.Target.handleMessage(int, Object).- Parameters:
payload- The message payload.- Returns:
- This message.
- Throws:
IllegalStateException- Ifsend()has already been called.
-
getPayload
@Nullable public Object getPayload()
Deprecated.Returns the message payload forwarded toPlayerMessage.Target.handleMessage(int, Object).
-
setHandler
@CanIgnoreReturnValue @Deprecated public PlayerMessage setHandler(Handler handler)
Deprecated.UsesetLooper(Looper)instead.
-
setLooper
@CanIgnoreReturnValue public PlayerMessage setLooper(Looper looper)
Deprecated.Sets theLooperthe message is delivered on.- Parameters:
looper- ALooper.- Returns:
- This message.
- Throws:
IllegalStateException- Ifsend()has already been called.
-
getPositionMs
public long getPositionMs()
Deprecated.Returns position in the media item atgetMediaItemIndex()at which the message will be delivered, in milliseconds. IfC.TIME_UNSET, the message will be delivered immediately. IfC.TIME_END_OF_SOURCE, the message will be delivered at the end of the media item atgetMediaItemIndex().
-
setPosition
@CanIgnoreReturnValue public PlayerMessage 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, orC.TIME_END_OF_SOURCEto deliver the message at the end of the current media item.- Returns:
- This message.
- Throws:
IllegalStateException- Ifsend()has already been called.
-
setPosition
@CanIgnoreReturnValue public PlayerMessage 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 indexmediaItemIndexat which the message will be sent, in milliseconds, orC.TIME_END_OF_SOURCEto deliver the message at the end of the media item with indexmediaItemIndex.- Returns:
- This message.
- Throws:
IllegalSeekPositionException- If the timeline returned bygetTimeline()is not empty and the provided media item index is not within the bounds of the timeline.IllegalStateException- Ifsend()has already been called.
-
getMediaItemIndex
public int getMediaItemIndex()
Deprecated.Returns media item index at which the message will be delivered.
-
setDeleteAfterDelivery
@CanIgnoreReturnValue public PlayerMessage 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 withsetPosition(long).- Parameters:
deleteAfterDelivery- Whether the message is deleted after delivery.- Returns:
- This message.
- Throws:
IllegalStateException- Ifsend()has already been called.
-
getDeleteAfterDelivery
public boolean getDeleteAfterDelivery()
Deprecated.Returns whether the message will be deleted after delivery.
-
send
@CanIgnoreReturnValue public PlayerMessage send()
Deprecated.Sends the message. If the target throws anExoPlaybackExceptionthen it is propagated out of the player as an error usingPlayer.Listener.onPlayerError(PlaybackException).- Returns:
- This message.
- Throws:
IllegalStateException- If this message has already been sent.
-
cancel
@CanIgnoreReturnValue public PlayerMessage cancel()
Deprecated.Cancels the message delivery.- Returns:
- This message.
- Throws:
IllegalStateException- If this method is called beforesend().
-
isCanceled
public boolean isCanceled()
Deprecated.Returns whether the message delivery has been canceled.
-
markAsProcessed
public void markAsProcessed(boolean isDelivered)
Deprecated.Marks the message as processed. Should only be called by aPlayerMessage.Senderand 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 withisDeliveredset to true at least once.
-
blockUntilDelivered
public boolean blockUntilDelivered() throws InterruptedExceptionDeprecated.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
looperas it would cause a deadlock.- Returns:
- Whether the message was delivered successfully.
- Throws:
IllegalStateException- If this method is called beforesend().IllegalStateException- If this method is called on the same thread used by the messagelooper.InterruptedException- If the current thread is interrupted while waiting for the message to be delivered.
-
blockUntilDelivered
public boolean blockUntilDelivered(long timeoutMs) throws InterruptedException, TimeoutExceptionDeprecated.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
looperas 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 beforesend().IllegalStateException- If this method is called on the same thread used by the messagelooper.TimeoutException- If thetimeoutMselapsed 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.
-
-