Class PlayerMessage

    • Constructor Detail

    • Method Detail

      • getLooper

        public Looper getLooper()
        Returns the Looper the message is delivered on.
      • setPosition

        public PlayerMessage setPosition​(long positionMs)
        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.
      • setPosition

        public PlayerMessage setPosition​(int mediaItemIndex,
                                         long positionMs)
        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.
      • getMediaItemIndex

        public int getMediaItemIndex()
        Returns media item index at which the message will be delivered.
      • setDeleteAfterDelivery

        public PlayerMessage setDeleteAfterDelivery​(boolean deleteAfterDelivery)
        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.
      • getDeleteAfterDelivery

        public boolean getDeleteAfterDelivery()
        Returns whether the message will be deleted after delivery.
      • isCanceled

        public boolean isCanceled()
        Returns whether the message delivery has been canceled.
      • markAsProcessed

        public void markAsProcessed​(boolean isDelivered)
        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.
      • blockUntilDelivered

        public boolean blockUntilDelivered()
                                    throws InterruptedException
        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.
      • blockUntilDelivered

        public boolean blockUntilDelivered​(long timeoutMs)
                                    throws InterruptedException,
                                           TimeoutException
        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.