Class MediaSessionConnector

    • Field Detail

      • ALL_PLAYBACK_ACTIONS

        public static final long ALL_PLAYBACK_ACTIONS
        Deprecated.
        See Also:
        Constant Field Values
      • DEFAULT_PLAYBACK_ACTIONS

        public static final long DEFAULT_PLAYBACK_ACTIONS
        Deprecated.
        The default playback actions.
        See Also:
        Constant Field Values
      • EXTRAS_SPEED

        public static final String EXTRAS_SPEED
        Deprecated.
        The name of the PlaybackStateCompat float extra with the value of Player.getPlaybackParameters().speed.
        See Also:
        Constant Field Values
      • mediaSession

        public final android.support.v4.media.session.MediaSessionCompat mediaSession
        Deprecated.
        The wrapped MediaSessionCompat.
    • Constructor Detail

      • MediaSessionConnector

        public MediaSessionConnector​(android.support.v4.media.session.MediaSessionCompat mediaSession)
        Deprecated.
        Creates an instance.
        Parameters:
        mediaSession - The MediaSessionCompat to connect to.
    • Method Detail

      • setPlayer

        public void setPlayer​(@Nullable
                              Player player)
        Deprecated.
        Sets the player to be connected to the media session. Must be called on the same thread that is used to access the player.
        Parameters:
        player - The player to be connected to the MediaSession, or null to disconnect the current player.
      • setEnabledPlaybackActions

        public void setEnabledPlaybackActions​(long enabledPlaybackActions)
        Deprecated.
        Sets the enabled playback actions.
        Parameters:
        enabledPlaybackActions - The enabled playback actions.
      • setCustomErrorMessage

        public void setCustomErrorMessage​(@Nullable
                                          CharSequence message)
        Deprecated.
        Sets a custom error on the session.

        This sets the error code via PlaybackStateCompat.Builder.setErrorMessage(int, CharSequence). By default, the error code will be set to PlaybackStateCompat.ERROR_CODE_APP_ERROR.

        Parameters:
        message - The error string to report or null to clear the error.
      • setCustomErrorMessage

        public void setCustomErrorMessage​(@Nullable
                                          CharSequence message,
                                          int code)
        Deprecated.
        Sets a custom error on the session.
        Parameters:
        message - The error string to report or null to clear the error.
        code - The error code to report. Ignored when message is null.
      • setCustomErrorMessage

        public void setCustomErrorMessage​(@Nullable
                                          CharSequence message,
                                          int code,
                                          @Nullable
                                          Bundle extras)
        Deprecated.
        Sets a custom error on the session.
        Parameters:
        message - The error string to report or null to clear the error.
        code - The error code to report. Ignored when message is null.
        extras - Extras to include in reported PlaybackStateCompat.
      • setCustomActionProviders

        public void setCustomActionProviders​(@Nullable
                                             MediaSessionConnector.CustomActionProvider... customActionProviders)
        Deprecated.
        Sets custom action providers. The order of the MediaSessionConnector.CustomActionProviders determines the order in which the actions are published.
        Parameters:
        customActionProviders - The custom action providers, or null to remove all existing custom action providers.
      • setMediaMetadataProvider

        public void setMediaMetadataProvider​(@Nullable
                                             MediaSessionConnector.MediaMetadataProvider mediaMetadataProvider)
        Deprecated.
        Sets a provider of metadata to be published to the media session. Pass null if no metadata should be published.
        Parameters:
        mediaMetadataProvider - The provider of metadata to publish, or null if no metadata should be published.
      • setDispatchUnsupportedActionsEnabled

        public void setDispatchUnsupportedActionsEnabled​(boolean dispatchUnsupportedActionsEnabled)
        Deprecated.
        Sets whether actions that are not advertised to the MediaSessionCompat will be dispatched either way. Default value is false.
      • setClearMediaItemsOnStop

        public void setClearMediaItemsOnStop​(boolean clearMediaItemsOnStop)
        Deprecated.
        Sets whether media items are cleared from the playlist when a client sends a MediaControllerCompat.TransportControls.stop() command.
      • setMapStateIdleToSessionStateStopped

        public void setMapStateIdleToSessionStateStopped​(boolean mapIdleToStopped)
        Deprecated.
        Sets whether Player.STATE_IDLE should be mapped to PlaybackStateCompat.STATE_STOPPED. The default is false Player.STATE_IDLE which maps to PlaybackStateCompat.STATE_NONE.
      • setMetadataDeduplicationEnabled

        public void setMetadataDeduplicationEnabled​(boolean metadataDeduplicationEnabled)
        Deprecated.
        Sets whether MediaSessionConnector.MediaMetadataProvider.sameAs(MediaMetadataCompat, MediaMetadataCompat) should be consulted before calling MediaSessionCompat.setMetadata(MediaMetadataCompat).

        Note that this comparison is normally only required when you are using media sources that may introduce duplicate updates of the metadata for the same media item (e.g. live streams).

        Parameters:
        metadataDeduplicationEnabled - Whether to deduplicate metadata objects on invalidation.
      • invalidateMediaSessionMetadata

        public final void invalidateMediaSessionMetadata()
        Deprecated.
        Updates the metadata of the media session.

        Apps normally only need to call this method when the backing data for a given media item has changed and the metadata should be updated immediately.

        The MediaMetadataCompat which is published to the session is obtained by calling MediaSessionConnector.MediaMetadataProvider.getMetadata(Player).

      • invalidateMediaSessionPlaybackState

        public final void invalidateMediaSessionPlaybackState()
        Deprecated.
        Updates the playback state of the media session.

        Apps normally only need to call this method when the custom actions provided by a MediaSessionConnector.CustomActionProvider changed and the playback state needs to be updated immediately.

      • invalidateMediaSessionQueue

        public final void invalidateMediaSessionQueue()
        Deprecated.
        Updates the queue of the media session by calling MediaSessionConnector.QueueNavigator.onTimelineChanged(Player).

        Apps normally only need to call this method when the backing data for a given queue item has changed and the queue should be updated immediately.

      • registerCustomCommandReceiver

        public void registerCustomCommandReceiver​(@Nullable
                                                  MediaSessionConnector.CommandReceiver commandReceiver)
        Deprecated.
        Registers a custom command receiver for responding to commands delivered via MediaSessionCompat.Callback.onCommand(String, Bundle, ResultReceiver).

        Commands are only dispatched to this receiver when a player is connected.

        Parameters:
        commandReceiver - The command receiver to register.
      • unregisterCustomCommandReceiver

        public void unregisterCustomCommandReceiver​(@Nullable
                                                    MediaSessionConnector.CommandReceiver commandReceiver)
        Deprecated.
        Unregisters a previously registered custom command receiver.
        Parameters:
        commandReceiver - The command receiver to unregister.