Interface SessionCallbackBuilder.AllowedCommandProvider

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean acceptConnection​(androidx.media2.session.MediaSession session, androidx.media2.session.MediaSession.ControllerInfo controllerInfo)
      Called to query whether to allow connection from the controller.
      androidx.media2.session.SessionCommandGroup getAllowedCommands​(androidx.media2.session.MediaSession session, androidx.media2.session.MediaSession.ControllerInfo controllerInfo, androidx.media2.session.SessionCommandGroup baseAllowedSessionCommands)
      Called to query allowed commands in following cases: A MediaController requests to connect, and allowed commands is required to tell initial allowed commands.
      int onCommandRequest​(androidx.media2.session.MediaSession session, androidx.media2.session.MediaSession.ControllerInfo controllerInfo, androidx.media2.session.SessionCommand command)
      Called when a MediaController has called an API that controls SessionPlayer set to the MediaSession.
    • Method Detail

      • getAllowedCommands

        androidx.media2.session.SessionCommandGroup getAllowedCommands​(androidx.media2.session.MediaSession session,
                                                                       androidx.media2.session.MediaSession.ControllerInfo controllerInfo,
                                                                       androidx.media2.session.SessionCommandGroup baseAllowedSessionCommands)
        Called to query allowed commands in following cases:
        • A MediaController requests to connect, and allowed commands is required to tell initial allowed commands.
        • Underlying SessionPlayer state changes, and allowed commands may be updated via MediaSession.setAllowedCommands(androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommandGroup).

        The provided baseAllowedSessionCommand is built automatically based on the state of the SessionPlayer, SessionCallbackBuilder.RatingCallback, SessionCallbackBuilder.MediaItemProvider, SessionCallbackBuilder.CustomCommandProvider, and SessionCallbackBuilder.SkipCallback so may be a useful starting point for any required customizations.

        Parameters:
        session - The media session.
        controllerInfo - The MediaSession.ControllerInfo for the controller for which allowed commands are being queried.
        baseAllowedSessionCommands - Base allowed session commands for customization.
        Returns:
        The allowed commands for the controller.
        See Also:
        MediaSession.SessionCallback.onConnect(MediaSession, ControllerInfo)
      • onCommandRequest

        int onCommandRequest​(androidx.media2.session.MediaSession session,
                             androidx.media2.session.MediaSession.ControllerInfo controllerInfo,
                             androidx.media2.session.SessionCommand command)
        Called when a MediaController has called an API that controls SessionPlayer set to the MediaSession.
        Parameters:
        session - The media session.
        controllerInfo - A MediaSession.ControllerInfo that needs allowed command update.
        command - A SessionCommand from the controller.
        Returns:
        A session result code defined in SessionResult.
        See Also:
        MediaSession.SessionCallback.onCommandRequest(androidx.media2.session.MediaSession, androidx.media2.session.MediaSession.ControllerInfo, androidx.media2.session.SessionCommand)