Class SessionCallbackBuilder


  • public final class SessionCallbackBuilder
    extends Object
    Builds a MediaSession.SessionCallback with various collaborators.
    See Also:
    MediaSession.SessionCallback
    • Method Detail

      • setMediaItemProvider

        public SessionCallbackBuilder setMediaItemProvider​(@Nullable
                                                           SessionCallbackBuilder.MediaItemProvider mediaItemProvider)
        Sets the SessionCallbackBuilder.MediaItemProvider that will convert media ids to MediaItems.
        Parameters:
        mediaItemProvider - The media item provider.
        Returns:
        This builder.
        See Also:
        MediaSession.SessionCallback.onCreateMediaItem(MediaSession, ControllerInfo, String), MediaController.addPlaylistItem(int, String), MediaController.replacePlaylistItem(int, String), MediaController.setMediaItem(String), MediaController.setPlaylist(List, MediaMetadata)
      • setSkipCallback

        public SessionCallbackBuilder setSkipCallback​(@Nullable
                                                      SessionCallbackBuilder.SkipCallback skipCallback)
        Sets the SessionCallbackBuilder.SkipCallback to handle skip backward and skip forward.
        Parameters:
        skipCallback - The skip callback.
        Returns:
        This builder.
        See Also:
        MediaSession.SessionCallback.onSkipBackward(MediaSession, ControllerInfo), MediaSession.SessionCallback.onSkipForward(MediaSession, ControllerInfo), MediaController.skipBackward(), MediaController.skipForward()
      • setRewindIncrementMs

        public SessionCallbackBuilder setRewindIncrementMs​(int rewindMs)
        Sets the rewind increment in milliseconds.
        Parameters:
        rewindMs - The rewind increment in milliseconds. A non-positive value will cause the rewind to be disabled.
        Returns:
        This builder.
        See Also:
        MediaSession.SessionCallback.onRewind(MediaSession, MediaSession.ControllerInfo), setSeekTimeoutMs(int)
      • setFastForwardIncrementMs

        public SessionCallbackBuilder setFastForwardIncrementMs​(int fastForwardMs)
        Sets the fast forward increment in milliseconds.
        Parameters:
        fastForwardMs - The fast forward increment in milliseconds. A non-positive value will cause the fast forward to be disabled.
        Returns:
        This builder.
        See Also:
        MediaSession.SessionCallback.onFastForward(MediaSession, MediaSession.ControllerInfo), setSeekTimeoutMs(int)
      • setSeekTimeoutMs

        public SessionCallbackBuilder setSeekTimeoutMs​(int seekTimeoutMs)
        Sets the timeout in milliseconds for fast forward and rewind operations, or 0 for no timeout. If a timeout is set, controllers will receive an error if the session's call to SessionPlayer.seekTo(long) takes longer than this amount of time.
        Parameters:
        seekTimeoutMs - A timeout for SessionPlayer.seekTo(long). A non-positive value will wait forever.
        Returns:
        This builder.
      • build

        public androidx.media2.session.MediaSession.SessionCallback build()
        Builds MediaSession.SessionCallback.
        Returns:
        A new callback for a media session.